Winsock problem.
-
Hi, I dont know whether this is the right place for this question, Please excuse if it is not so,. I have just started programming in winsock. How is my server intimated that one of the clients has sent it some data? should I have a loop with the recv(....) function so that it checks continuously for incoming data? Or are there anyother options? (Windows is my OS) Thanks, Deepak Samuel.
-
Hi, I dont know whether this is the right place for this question, Please excuse if it is not so,. I have just started programming in winsock. How is my server intimated that one of the clients has sent it some data? should I have a loop with the recv(....) function so that it checks continuously for incoming data? Or are there anyother options? (Windows is my OS) Thanks, Deepak Samuel.
Use
accept()
. I had a little server application that used the following functions:WSAStartup()
socket()
bind()
listen()
accept() in loop
closesocket()
WSACleanup()
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
-
Hi, I dont know whether this is the right place for this question, Please excuse if it is not so,. I have just started programming in winsock. How is my server intimated that one of the clients has sent it some data? should I have a loop with the recv(....) function so that it checks continuously for incoming data? Or are there anyother options? (Windows is my OS) Thanks, Deepak Samuel.
If you want to wade through some stuff, this link http://www.vijaymukhi.com/vmis/vmchap4.htm should show you an easier way using winsock 2 (that won't freeze your application). wWw.KruncherInc.cOm
-
Hi, I dont know whether this is the right place for this question, Please excuse if it is not so,. I have just started programming in winsock. How is my server intimated that one of the clients has sent it some data? should I have a loop with the recv(....) function so that it checks continuously for incoming data? Or are there anyother options? (Windows is my OS) Thanks, Deepak Samuel.
what kind of sockets are you using? TCP or UDP? There are 4 (as far as I know) ways to get informed about incoming data. these ways are: - blocking sockets (call recv() and what till it returns control to your app) - use select() to check whether there is activity on the socket - use WSAEventSelect() to assign an EVENT to a socket and then wait for the event - use WSAAsyncSelect() to make the socket send window messages when there is activity If you want to create a server which has a main window, then the forth way could be interesting. If your server doesn't have a window: - For servers (TCP) with only few clients or UDP servers you should use way one. - For servers (TCP) with many clients I'd prefer way two (It's also linux compatible :)). I hope I could help.... Don't try it, just do it! ;-)