Re: receiving data with soreceive
Re: receiving data with soreceive
- Subject: Re: receiving data with soreceive
- From: Bijoy Thomas <email@hidden>
- Date: Sat, 14 May 2005 18:33:33 -0400
I am using SOCK_STREAM. What i am trying to do is set up a connection
with an ftp server. I call soconnect and then soreceive to get the
welcome message. I then send the username and call soreceive to get the
message asking for the passwd. Then i send the passwd and call
soreceive to get the login message. Each time, the data send by the
server varies.
Regards,
Bijoy Thomas.
On May 14, 2005, at 6:23 PM, Justin Walker wrote:
On May 14, 2005, at 14:36, Bijoy Thomas wrote:
How can i tell soreceive to get me whatever data has come upto a
maximum length. I am trying to receive data from a server and the
maximum length of data it can send is 100 bytes. If i specify
auio.uio_resid = 100 and the server sends less than 100 bytes, the
soreceive blocks. If i give a small value like 50 and the server
sends 75 bytes, i miss out on the remaining 25 bytes. The flag is am
using is MSG_WAITALL and I am using mbufs to receive my data. Should
i try a soreceive with MSG_PEEK, get the length of data and then use
that length to call soreceive?
Although you don't say, I gather you are using a SOCK_DGRAM socket,
correct?
MSG_PEEK is a reasonable way to do this, if your "protocol" gives you
the packet length up front.
In case no one has mentioned it, you should consider an investment in
W. Richard Stevens' books (Unix Network Programming, V1; and TCP/IP
Illustrated, V2). They deal with just this kind of issue, the former
at user level, the latter in the kernel (although the latter is a
"code walkthrough" of an early BSD networking stack, rather than a
programming guide).
Regards,
Justin
--
Justin C. Walker, Curmudgeon-At-Large
Institute for General Semantics
--------
"Weaseling out of things is what separates us from the animals.
Well, except the weasel."
- Homer J Simpson
--------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden