🔒 Locked
recv problem
Advertisement
Original Post
I''m writing a server application to run on a *nix machine, and the clients are coded using winsock. Everytime I send a packet from the client and the server receives it, the return value from recv is -1. Any ideas? I''ve really been staring at this one for a while... I''m thinking there''s an issue here I''m not aware of.
Thanks for your time
quote:
Original post by Anonymous Poster
When recv() fails, call GetLastError() and look up the error code in MSDN. If the error code doesn''t make sense, post it here along with some code.
Sounds good, except the recv call is being done on a *nix platform. If the clientside is generating an error too, then he could call GetLastError().
Thanks for your prompt replies everybody 
--I printed errno, here's what it's giving me:
Bad address
Does this mean I'm attempting recv on the wrong socket somehow, or what? What sorts of things can cause a bad address error?
Let me add a little more information:
I have some debugging script in there that's telling me I'm doing an recv on the same socket that's being disconnected after the -1 is returned from recv.
[edited by - McDanger on April 19, 2004 11:03:20 AM]
[edited by - McDanger on April 19, 2004 11:07:00 AM]
--I printed errno, here's what it's giving me:
Bad address
Does this mean I'm attempting recv on the wrong socket somehow, or what? What sorts of things can cause a bad address error?
Let me add a little more information:
I have some debugging script in there that's telling me I'm doing an recv on the same socket that's being disconnected after the -1 is returned from recv.
[edited by - McDanger on April 19, 2004 11:03:20 AM]
[edited by - McDanger on April 19, 2004 11:07:00 AM]
Figured out what was wrong.
Basically -- the buffer I was passing wasn''t initialized. Yes, a newbie mistake I was furious at myself over -- but not as furious as I was over the "Bad address" error message. I didn''t even think to check for something as stupid as not having initialized my buffer because it said "Bad address" and I instantly though my socket was messed up.
Thanks for your time trying to figure this out, guys!
Basically -- the buffer I was passing wasn''t initialized. Yes, a newbie mistake I was furious at myself over -- but not as furious as I was over the "Bad address" error message. I didn''t even think to check for something as stupid as not having initialized my buffer because it said "Bad address" and I instantly though my socket was messed up.
Thanks for your time trying to figure this out, guys!
The "address" in question was probably the address you passed into recv(), i e a pointer value kind of address, not a network kind of address.
Also, I recommend you start using recvfrom(). You''ll realize that you want it soon enough anyway (say, to make client/server work through NAT).
Also, I recommend you start using recvfrom(). You''ll realize that you want it soon enough anyway (say, to make client/server work through NAT).
quote:
Original post by hplus0603
The "address" in question was probably the address you passed into recv(), i e a pointer value kind of address, not a network kind of address.
Also, I recommend you start using recvfrom(). You''ll realize that you want it soon enough anyway (say, to make client/server work through NAT).
I thought recvfrom was for UDP?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement