Re: How to stop listening on a port?
Re: How to stop listening on a port?
- Subject: Re: How to stop listening on a port?
- From: Hasan Diwan <email@hidden>
- Date: Mon, 11 Nov 2002 00:00:59 -0800
read() is blocking until it receives at least one byte. To interrupt
it, wait until a time then issue an alarm() from another thread. The
following should solve your issue:
int readBytes=read(sd, &foo, 255);
if (readBytes == 0) { // client closed connection
close(sd);
}
if (readBytes < 0) // check errno for what's wrong, most likely,
connection will need to be
// closed.
On Sunday, November 10, 2002, at 09:57 AM, Andreas Mayer wrote:
>
>
This starts a background thread that seems to call read() internally.
>
read() is a blocking call and will not return when the port is closed.
>
My solution was to do the reading myself. It's some work though, if
>
you don't want to poll.
Hasan Diwan
OpenPGP KeyID: 0xBE42DCA6
Fingerprint: 1CB0 47E3 0A24 DAC1 DCCA 4225 F166 40C2 BE42 DCA6
http://www.cs.rpi.edu/~diwanh/gpg.key
[demime 0.98b removed an attachment of type application/pgp-signature which had a name of PGP.sig]
_______________________________________________
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.