Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>here is the solution , when you create the <code>CFHTTPMessage</code> you should serialize it (for example in my code I used UTF8 ) and then write to to server . </p> <p>here is my code sample you can follow this example it is working great :</p> <pre><code>CFHTTPMessageRef myRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault,CFSTR("POST"), myURL, kCFHTTPVersion1_1); CFHTTPMessageSetHeaderFieldValue(myRequest, CFSTR("Content-Type"), CFSTR("application/x-www-form-urlencoded")); CFHTTPMessageSetHeaderFieldValue(myRequest, CFSTR("Content-Length"), (CFStringRef)postLength); CFHTTPMessageSetBody(myRequest, (CFDataRef)postData); // postData is NSData dataReadStream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, myRequest); </code></pre> <p>//// From here Is Connection To Server </p> <pre><code>CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (CFStringRef) serverHost, serverPort, &amp;dataReadStream, &amp;dataWriteStream); if (dataReadStream &amp;&amp; dataWriteStream) { CFReadStreamSetProperty(dataReadStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue); CFWriteStreamSetProperty(dataWriteStream, kCFStreamPropertyShouldCloseNativeSocket, kCFBooleanTrue); iStream = (NSInputStream *)dataReadStream; [iStream retain]; [iStream setDelegate:self]; [iStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [iStream open]; oStream = (NSOutputStream *)dataWriteStream; [oStream retain]; [oStream setDelegate:self]; [oStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [oStream open]; </code></pre> <p>///Now Write Your Command To Server</p> <pre><code>NSString *content = [NSString stringWithFormat:@"Your Command"]; NSString *req = [NSString stringWithFormat:@"POST /client HTTP/1.1\r\nContent-Length: %d\r\n\r\n%@\r\n", [content length], content]; [oStream write:(const UInt8 *)[req UTF8String] maxLength:strlen((char*)[req UTF8String])]; </code></pre> <p>then receive the notification in just dont Forget to add to header file</p> <pre><code>-(void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload