🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
How to use recv()...
I''ve been playing around with sending and recieving messages, but I have yet to get it perfect. Does anyone want to copy\paste a function that they have made to resieve a message? The problem I''ve been having is when I revieve a message, I get it, but my program never stops getting "FD_READ" messages. I think it is because I didn''t recieve the data properly, but I don'' know where I went wrong. Any help would be greatly appreciated. Also, if you could not use vector<> I''d appreciate it. Thanks.
Are you using Window''s asynchronous sockets ?
If so you''re supposed to recv() when you get a FD_READ message.
I can''t help you more with that part. I use select()
http://www.gamedev.net/community/forums/topic.asp?topic_id=68385
A basic call to recv() is done that way :
That''s it.
If so you''re supposed to recv() when you get a FD_READ message.
I can''t help you more with that part. I use select()
http://www.gamedev.net/community/forums/topic.asp?topic_id=68385
A basic call to recv() is done that way :
#define BUFSIZE 1024char buffer[bufsize]int bytes_read = recv( socket, buffer, BUFSIZE, NULL );
That''s it.
currently, all my basic network functions are inside of a class. the listen function is in a thread, so the code looks a bit like this
it uses udp, so im not sure if this is what your looking for, but it might give ya a better idea![](smile.gif)
char buffer[1024];while(1){ int recieved = recvfrom(...); // recieve stuff here if (recieved > 0) { buffer[recieved] = 0; // do something with the buffer here }}
it uses udp, so im not sure if this is what your looking for, but it might give ya a better idea
![](smile.gif)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement