title: Unable to Write On CFWriteStreamWrite
body: <p>i am having trouble in writing data to CFStream.</p>
  
  <pre><code>// i am getting the CFSocketRef and then from it getting native Handle.
  CFSocketNativeHandle sock = CFSocketGetNative( [appDelegate getSocketRef]);
  </code></pre>
  
  <p>Does above Code return me the same handler of the created socket?what ever i write onto stream will be written on the created socket?</p>
  
  <pre><code>// and then wrote 
  CFStreamCreatePairWithSocket(kCFAllocatorDefault,  sock,
                                   &amp;readStream, &amp;writeStream);    
      if (!readStream || !writeStream) {
          // close([appDelegate TCPClient]);
          // close(sock);
          fprintf(stderr, "CFStreamCreatePairWithSocket() failed\n");
          return;
      }
  </code></pre>
  
  <p>above works fine,it does not give me failed message </p>
  
  <pre><code>// does not give error ,else portion is executed
  if (!CFWriteStreamOpen(writeStream)) {
          CFStreamError myErr = CFWriteStreamGetError(writeStream);
          // An error has occurred.
          if (myErr.domain == kCFStreamErrorDomainPOSIX) {
              // Interpret myErr.error as a UNIX errno.
              NSLog(@"kCFStreamErrorDomainPOSIX");
          } else if (myErr.domain == kCFStreamErrorDomainMacOSStatus) {
              // Interpret myErr.error as a MacOS error code.
              OSStatus macError = (OSStatus)myErr.error;
              // Check other error domains.
              NSLog(@"kCFStreamErrorDomainMacOSStatus");
          }
      }else
  
      /* Send the connect call to stream */
    //  while (send_len &lt; (originalLength + 1)) 
      {
        //  if (CFWriteStreamCanAcceptBytes(writeStream)) 
          {
              //UInt8 buf[] = "Hello, world";//(unsigned char *) "connectStream" 
              //CFIndex bufLen = (CFIndex)strlen(buf);
              bytes = CFWriteStreamWrite(writeStream,
                                         (unsigned char *) connectStream,
                                         originalLength );
  
              NSLog(@"%@",[[NSString alloc] initWithData:connectStream encoding:NSASCIIStringEncoding] );
              if (bytes &lt; 0) {
                  fprintf(stderr, "CFWriteStreamWrite() failed\n");
                  // close(sock);
                  return;
              }
              send_len += bytes;
          }
          // close(sock);
          CFReadStreamClose(readStream);
          CFWriteStreamClose(writeStream);
          return;
      }
  </code></pre>
  
  <p>CFWriteStreamCanAcceptBytes always return false so i have commented it and directly wrote bytes,and it blocks the call and does not return any thing neither any byte is written on to the stream,
  Can any one please guide me in this rergard?
  is there any other way of doing this?</p>
  
  <p>Regards,
  Aamir</p>