Winsock...

Started by
1 comment, last by Zoot 22 years ago
Hi, I am having a problem with reading the incoming data... i use: "send (ctClient.ClientSocket, sendbuffer, strlen(sendbuffer), 0);" to send the data and then to read: "int err = recv(ctClient.ClientSocket, packet, sizeof(packet), 0 );" My qestion is: is it possible to only read one packet at once? And if it, how? Thanks, Zoot
GSACP: GameDev Society Against Crap PostingTo join: Put these lines in your signature and don't post crap!
Advertisement
If I read this right then you''re talking about stream sockets. Stream sockets don''t base on packets until a long way down the layers. You don''t read packets but data that was recieved on a stream since the last read() or estalbishing the link.
You basically could try to implement some kind of protocol (like putting the length of the sent data at the beginning of a send-buffer) if you need it. A good point to start at (though perhaps not so much for winsock) would be Beej''s Guide to Network Programming.
I believe there are no guarantees how much data you will get per call with recv except it will be less than or equal to your declared buffer size. Just keep calling recv until you receive 0 bytes.
_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.

This topic is closed to new replies.

Advertisement