• 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
Re: Select problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Select problem


  • Subject: Re: Select problem
  • From: "Matt Slot" <email@hidden>
  • Date: Tue, 6 Apr 2004 17:21:14 -0400

Mike Cohen (email@hidden) wrote:
>I'm rewriting some old code which used OT with an asynchronous notifier
>to use sockets with select. I have a thread running the following code,
>which as far as I can tell is a pretty standard select loop. It works
>correctly the first time - select returns when data is ready and I read
>the 149 byte packet correctly. However, after that select returns
>immediately and read returns 0 bytes and it continues like that until I
>stop it.

First, generally you should use send() and recv() instead of write() and
read() with sockets, as they provide a few option flags that you may want.
It's also more consistent when you go to sendto() and recvfrom() with UDP
endpoints.

Second, for stream endpoints, recv() and read() return 0 bytes to indicate
the peer endpoint has initiated an orderly disconnect (shutdown). You will
no longer receive data from it, and depending on the high level protocol,
you may continue sending data or just close the endpoint.

Matt

+--------------------------+-----------------------------------+
| Matt Slot | Ambrosia Software, Inc. |
| Bitwise Operator | http://www.AmbrosiaSW.com/ |
+--------------------------+-----------------------------------+
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.


References: 
 >Select problem (From: Mike Cohen <email@hidden>)

  • Prev by Date: Select problem
  • Next by Date: MAC address spoofing over airport
  • Previous by thread: Select problem
  • Next by thread: MAC address spoofing over airport
  • Index(es):
    • Date
    • Thread