WinSock to CFSocket problems
WinSock to CFSocket problems
- Subject: WinSock to CFSocket problems
- From: Ken Baer <email@hidden>
- Date: Mon, 4 Apr 2005 17:00:20 -0700
I am trying to port some Winsock code to OS X. I have a server app that is running on the PC. On the Mac side, the code is cross platform and is calling Winsock functions that I have rewritten to use BSD sockets and CFSockets. Yes, I know this sounds convoluted, but we have a Win32 portability library that we wrote, and I'm trying to get this working in a more general way so this solution will work for multiple apps.
I am able to connect to the PC server from the Mac using BSD socket functions. I am using
CFSocketCreateWithNative() to get CFSocket from the BSD socket, and install a network event callback function. In that function, I have the following code:
case kCFSocketDataCallBack:
event = FD_READ;
CFDataGetBytes( address, CFRangeMake(0,CFDataGetLength( address )), sockdata->m_ReceivedData );
sockdata->m_AmountBuffered = CFDataGetLength( address );
break;
The pointer sockdata->m_ReceivedData is allocated with the size
64 * 1024.
The problem is that the data I am getting sent back is nothing like what the server is sending. Here's what's happening.
The server is sending a stream of 27 bytes:
17 00 00 00 92 c1 77 41 fd 27 f0 84 3c 64 b4 7f 2b 23 28 a4 8f 69 f8 25 7e bc 1f
What I get in my buffer after the CFDataGetBytes() is 16 bytes:
10 02 03 85 c0 a8 01 7f 00 00 00 00 00 00 00 00
I hope I have included enough information to make this clear. I have traced the heck out of this and don't have any more ideas of things to try. When I trace the PC client, I get the exact stream that the server sent.
I don't normally do a lot of networking code, so please let me know if I missed something obvious.
Thanks in advance.
-Ken Baer.
Hash, Inc.
email@hidden
_______________________________________________
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