• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem with connection via Proxy using CFNetwork in TCP stream
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with connection via Proxy using CFNetwork in TCP stream


  • Subject: Problem with connection via Proxy using CFNetwork in TCP stream
  • From: Yulia Bensman <email@hidden>
  • Date: Tue, 01 Dec 2015 16:57:44 +0000
  • Thread-topic: Problem with connection via Proxy using CFNetwork in TCP stream

Hello,

I am trying to implement connection via Proxy using the way recommended for CFStream in “Working with Streams” chapter (https://developer.apple.com/library/mac/documentation/Networking/Conceptual/CFNetwork/CFStreamTasks/CFStreamTasks.html)

In this stream, I want to communicate using our proprietary protocol, based on TCP and SSL. 

For some reason, I cannot connect to the server.
In the WireShark I see, that the client does not try to connect to proxy, but tries to connect to server directly.

The question is: if I can use this solution to communicate via Proxy for TCP-based stream?
Does somebody have any experience with this solution (preferably for TCP stream, not HTTP/HTTPS)? If yes, maybe something wrong in my code? (see below)

Thanks a lot,
Yulia

This is the code I try to run:


    CFReadStreamRef     readStream = NULL;
    CFWriteStreamRef    writeStream = NULL;
    ::CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (__bridge CFStringRef)hostAddress, portNum, &readStream, &writeStream);
    ::CFWriteStreamSetProperty(writeStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);
    ::CFReadStreamSetProperty(readStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue);

    CFDictionaryRef proxyDict = ::SCDynamicStoreCopyProxies(NULL);
    ::CFReadStreamSetProperty(readStream, kCFStreamPropertyHTTPProxy, proxyDict);

    [readStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
    [writeStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];

    [readStream open];
    [writeStream open];

I also tried to build the proxy dictionary in the code with the proxy name or IP, but it did not help.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem with connection via Proxy using CFNetwork in TCP stream
      • From: "Quinn \"The Eskimo!\"" <email@hidden>
  • Prev by Date: Re: How to use NWTCPConnectionAuthenticationDelegate for self signed certificate
  • Next by Date: Re: Problem with connection via Proxy using CFNetwork in TCP stream
  • Previous by thread: Re: How to use NWTCPConnectionAuthenticationDelegate for self signed certificate
  • Next by thread: Re: Problem with connection via Proxy using CFNetwork in TCP stream
  • Index(es):
    • Date
    • Thread