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
Sending data with CFSocket
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
][
Date Index
][
Thread Index
]
Sending data with CFSocket
Subject
:
Sending data with CFSocket
From: Ryan M Joseph <
email@hidden
>
Date: Fri, 21 Jan 2005 12:23:47 -0700
I am working a simple client/server application using CFSocket (for my first time) and ran into some problems when attempting sending data. I am not very experienced with sockets but I think I setup the the design as CFSocket intended. The program gets quite far before the problem so I will omit some details.
• First I setup CFSocketCreate (using AF_INET, SOCK_STREAM, IPPROTO_TCP, kCFSocketDataCallBack) for the server.
• Bind the local address (AF_INET family with the IP 127.0.0.1) using CFSocketSetAddress
• Last call CFSocketCreateRunLoopSource and add the source the current loop using CFRunLoopAddSource.
• This all works without error and CFSocketIsValid returns TRUE.
• I go on to setup the client socket using CFSocketCreate with the same parameters but with a kCFSocketConnectCallBack.
• Connect to the servers address using CFSocketConnectToAddress with a negative timeout value.
• Add the client socket runloop source like mentioned above.
• Again, no errors and the kCFSocketConnectCallBack returns the connected event without an error in the data parameter.
So it appears I have a properly connected socket? I then call CFSocketSendData with the client socket (no address parameter because the socket is connected to the address and with a FSSpec stored in CFDataRef) but it just crashes inside CFSocketSendData. Other strange bug is that the server socket returns a kCFSocketDataCallBack with an empty CFDataRef (not nil) before CFSocketSendData is ever called.
If you have experience with the API any help in telling me what I did wrong would be of great help. Or maybe I should just use CFStream to send/receive data? I read in a few places that this was the preferred method although I did not see an advantage. Thank you very much for your help.
_______________________________________________
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:
kCFStreamErrorHTTPParseFailure?
Next by Date:
system socket library?
Previous by thread:
Re: kCFStreamErrorHTTPParseFailure?
Next by thread:
system socket library?
Index(es):
Date
Thread