• 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
CFNetwork port to Intel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CFNetwork port to Intel


  • Subject: CFNetwork port to Intel
  • From: Jeff Heyob <email@hidden>
  • Date: Fri, 29 Jun 2007 09:30:55 -0400

Hi,
I have CFNework code that sets up a listening socket to accept incoming connection requests. It has been working fine when built against sdk10.3 using Xcode 2.4.1. I recently ported the supporting app to Intel against sdk10.4. The PPC built of the CFNetwork code works fine , but the Intel CFNetwork  code doesn't respond to any connection requests.
Here is the code. The "OpenListener" code executes with no error. There is no response to connection requests in the "ServerCall" code. I've tried the listenPort integer as both little and big endian with no luck.

I would really appreciate any help to get this to work on Intel.
Thanks,
Jeff

// ---------------------------------------------------------------------------------
// • OpenListener [public]
// ---------------------------------------------------------------------------------
OSStatus Network::OpenListener(UInt16 listenPort)
{
CFOptionFlags flags = kCFSocketAcceptCallBack;
CFSocketContext context = {0,this,nil,nil,nil};
CFSocketError err = kCFSocketError;
CFDataRef address;
struct sockaddr_in addrs = {8,AF_INET,CFSwapInt32BigToHost(listenPort),{0}};

mListenSocket = CFSocketCreate(nil,PF_INET,SOCK_STREAM,IPPROTO_TCP,flags,ServerCallBack,&context);
if(mListenSocket != nil)
{
RetainCt(this);
    int yes = 1;
    setsockopt(CFSocketGetNative(mListenSocket),SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(yes));
mListenRunLoopSrc = CFSocketCreateRunLoopSource(nil, mListenSocket, 0);
if(mListenRunLoopSrc)
{
CFRunLoopAddSource(CFRunLoopGetCurrent(), mListenRunLoopSrc, kCFRunLoopCommonModes);
    address = CFDataCreateWithBytesNoCopy(nil,(UInt8*)&addrs, sizeof(addrs), kCFAllocatorNull);
if(address)
{
    err = CFSocketSetAddress(mListenSocket, address);
    CFRelease(address);
}
}
}
return err;
}
// ---------------------------------------------------------------------------------
// • ServerCallBack [public]
// ---------------------------------------------------------------------------------
void Network::ServerCallBack(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *data, void *info)
{
Network* objRef = (Network*)info;
objRef->ServerCall( s,  type,  address,  data);
}
// ---------------------------------------------------------------------------------
// • ServerCall [public]
// ---------------------------------------------------------------------------------
void Network::ServerCall(CFSocketRef s, CFSocketCallBackType type, CFDataRef address, const void *nativeSocketH)
{
#pragma unused(s)
struct sockaddr_in* aptr;
Network* net = nil;
UInt32 peerAddress = 0;
SInt32 err;
switch(type)
{
case kCFSocketAcceptCallBack:
if(address != nil)
{
aptr = (struct sockaddr_in*)CFDataGetBytePtr(address);  
peerAddress = aptr->sin_addr.s_addr;
}
net = AcceptConnectionSelf(peerAddress);
if(net != nil)
{
if(net->AcceptConnection(address,*((CFSocketNativeHandle*)nativeSocketH)) == false)
{
delete net;
net = nil;
}
}
if(net == nil)
{
err = shutdown(*(int*)nativeSocketH, SHUT_RDWR);
err = close(*(int*)nativeSocketH);
}
break;
default:
break;
}
}
// ---------------------------------------------------------------------------------



 _______________________________________________
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: CFNetwork port to Intel
      • From: Frederick Cheung <email@hidden>
  • Prev by Date: FW: Bonjour IPv6
  • Next by Date: Re: CFNetwork port to Intel
  • Previous by thread: enabling IPv6 in Bonjour host side
  • Next by thread: Re: CFNetwork port to Intel
  • Index(es):
    • Date
    • Thread