• 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
sockets in threaded obj-C app.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sockets in threaded obj-C app.


  • Subject: sockets in threaded obj-C app.
  • From: Robert Tillyard <email@hidden>
  • Date: Fri, 20 Sep 2002 23:34:58 +0100

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.


Regards, Rob.
_______________________________________________
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.

  • Follow-Ups:
    • Re: sockets in threaded obj-C app.
      • From: Greg Titus <email@hidden>
  • Prev by Date: Re: per pixel reading from a tiff
  • Next by Date: needed Time for a method
  • Previous by thread: NSWindowExposedEventType
  • Next by thread: Re: sockets in threaded obj-C app.
  • Index(es):
    • Date
    • Thread