site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com But i guess this would just loop if the server sent exactly 20 bytes. Regards, Bijoy Thomas On May 14, 2005, at 6:59 PM, Brian Bergstrand wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On May 14, 2005, at 5:39 PM, Justin Walker wrote: On May 14, 2005, at 15:22, Bijoy Thomas wrote: Are you calling soreceive in an so upcall? If so, try setting MSG_DONTWAIT in the flags, and that should give you everything that is in the so buf at that point. MSG_DONTWAIT tells the socket not to block. For the auio resid, use M_COPYALL. This is an alternative, but keep in mind that using this means that your code has to make sure all the data you need is in place, essentially by reconstructing the incoming packet byte-by-byte (i.e., you need to make sure enough bytes are present to form a valid header so you can read the length, so you can make sure enough bytes are present to process the rest of the packet, ....). It also means you are polling for data, which may not be the best idea. Cheers, Justin Hmm, don't know where you got the polling from. upcalls are event based, so when there is data to read (or the sock is ready for writing) your upcall (callback) is called. If all of the data is not in the socket at that point, you buffer it and wait for the next event. No polling involved. However it does mean more work on your part because everything is async. Bijoy: Definitely get Stevens' TCP book as Justin recommended -- this is all covered in detail. Brian Bergstrand <http://www.bergstrand.org/brian/> PGP Key ID: 0xB6C7B6A2 -----BEGIN PGP SIGNATURE----- Version: PGP Desktop 9.0.1 (Build 2130) This email sent to bijoyjth@bluebottle.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... I tried using MSG_PEEK with soreceive and it does return the actual number of bytes that the server has sent. So i guess making a soreceive with MSG_PEEK followed by a soreceive call with uio_resid set should return whatever data the server sent. I also tried the following code do { auio.uio_resid = 20; result = soreceive(sock,NULL,&auio,&m,NULL,&flags); //flags = MSG_DONTWAIT } while ((auio.uio_resid == 0) || (auio.uio_resid == 20)); iQA/AwUBQoaC6nnR2Fu2x7aiEQJsJQCgjVA6tN8qdfqP9RS2KQiqiTrFvyUAnjcd AwNZPhnBaZUJWlvQIchE6kRa =zVVH -----END PGP SIGNATURE----- _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/ bijoyjth%40bluebottle.com This email sent to site_archiver@lists.apple.com