LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Socket Programming (https://www.linuxquestions.org/questions/linux-software-2/socket-programming-99402/)

perdesiz 10-02-2003 09:19 AM

Socket Programming
 
I read the guide about "Beej's Guide to Network Programming Using Internet Sockets"
I simply compiled the client and server programs and ran them. But there is a fact that the server waits to be connected and the client waits to be answered. Isn't that possible to implement the TCP/IP connection without waiting? I mean in a program which is supposed not to wait (a looping program) , can I implement the tcp/ip protocol with disabling that waiting action?And how?

bstempi 10-02-2003 11:41 AM

Correct me if my anser seems as if I misunderstood your question. I also read Beej's guide, and went on to do a lot of windows socket programming. I remember a little bit about that example at the end. The server MUST. If the server doesn't loop, then it will not answer any sockets that enter it's que. One thing you can do though is to put the server loop in it's own thread, that way the program doesn't seem as if it's hanging. As far as the client goes, you kida-sorta have to wait. If the server is busy and takes a few milliseconds over average to respond, the client will drop if no waiting action is implemented. The reason that waiting is implemented is for 2 reasons: (1) as far as the server goes, it doesn't know when connections are going to come in, so it doesn't know when to check. Solution: check it all the time! thus the looping; (2) when a client makes a request, the server WILL NOT respond that instant, so you need to implement SOMETHING that will allow the server a few milliseconds (or if it's really lagging, start counting in seconds) of time to do it's processing and respond. I hope this helped.

perdesiz 10-06-2003 12:15 AM

thank you for answering,
I contacted with Beej and solved the problem. select() command is the cure. Check it out its very useful...


All times are GMT -5. The time now is 03:36 PM.