Re: sockets in threaded obj-C app.
Re: sockets in threaded obj-C app.
- Subject: Re: sockets in threaded obj-C app.
- From: Greg Titus <email@hidden>
- Date: Fri, 20 Sep 2002 17:21:25 -0700
Hi Robert,
I can't be much specific help without seeing your code, but it is
definitely allowed and should work fine to call read() from any thread,
and it should not block any other thread. Your problem must lie
elsewhere.
Hope this helps,
-Greg
On Friday, September 20, 2002, at 03:34 PM, Robert Tillyard wrote:
I need to write an application that talks to a UNIX server via a
socket. The server sends commands in fixed length structures which
will cause the app to do some processing and occasionally send back
information. The user can also press buttons to send commands to the
UNIX server.
I thought that this ought to be threaded with the main code doing the
UI stuff and a 2nd thread hanging around for data on a socket. This is
my 2nd Cocoa app so this is still all new to me.
I have successfully managed to get a 2nd thread to run but I don't
know how to play with sockets in Obj-C so I linked in some 'C' code
from the server (the code works in a command line non-threaded test
utility) but when the 'C' code calls read() (from the thread) the
whole application hangs, I'm guessing you can't do that in a thread.
Is there any example code of socket handling in a thread anywhere? I'm
guessing I need NSPort and NSPortSocket? I just need to open a socket
and read fixed length data until the user quits.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.