• 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
CFSocketSendData -- what am I doing wrong?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CFSocketSendData -- what am I doing wrong?


  • Subject: CFSocketSendData -- what am I doing wrong?
  • From: Chilton Webb <email@hidden>
  • Date: Sat, 31 Dec 2005 23:12:59 -0600

Hi,

I have an application that is listening on a port via the following...
sender = CFSocketCreate(NULL, AF_INET, SOCK_STREAM, IPPROTO_TCP, clientCallbacks, myFunction, &context);
if (sender) {
struct sockaddr_in frameAddr;
frameAddr.sin_addr.s_addr = INADDR_ANY;
frameAddr.sin_port = ntohs(FramePort);
frameAddr.sin_family = AF_INET;


CFDataRef senderData = CFDataCreate(NULL, (const UInt8*) &frameAddr, sizeof(struct sockaddr_in));
if(CFSocketSetAddress(sender,senderData) != kCFSocketSuccess){
CFShow(CFSTR("false\rFailed to bind to the requested port."));
return;
}


// Schedule the run loop and add to the ref lists
FrameRunLoopSource = CFSocketCreateRunLoopSource(NULL, sender , 0);
CFRunLoopAddSource(CFRunLoopGetCurrent(), FrameRunLoopSource, kCFRunLoopCommonModes);
}


... and my function looks like this...
void myFunction(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void * data, void *info)
{
static int connected;
CFSocketError err = kCFSocketError;
if (type==kCFSocketDataCallBack) {
SendVersion(s);


    }
}

... and SendVersion does this...

int success = 1;
    CFSocketError err = kCFSocketSuccess;
    CFDataRef Data = CFDataCreate(NULL, (const UInt8*)data, len);
    CFDataRef address = CFSocketCopyPeerAddress(s);

    CFShow(address);

    err= CFSocketSendData (s,NULL,Data,0.0);
    if (err==kCFSocketError) {
        CFShow(CFSTR("Socket error on send."));
        success = 0;
    }
    return success;

......

When I get into SendVersion, it always returns kCFSocketError, and no data is sent. Also, address is NULL at this point. What am I doing wrong?

Thanks,
-Chilton
_______________________________________________
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


  • Prev by Date: Re: Devices accessing
  • Previous by thread: Re: Devices accessing
  • Index(es):
    • Date
    • Thread