![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 | |
|
Professional Programmer
|
Network flood?
I'm having a problem with my tcp server which seems to be having a problem receiving/sending data after the clients send a bunch of messages at once. Well actually, the messages can be pretty spread apart, but the server still seems to "lockup" until the user who was causing the mass packet, gets kicked or leaves the server. I know tcp is "special" for receiving everysingle packet, and wont move on until all packets have been received, but is there anyway I could speed the speed of the server so it doesn't take so long to receive, process data, then send to the clients again?
The server is used almost continuously and will most likely be flooded like this if I use it in a real situation if I put it out for people to use at the point it's at. Perhaps a message queue would be the best situation in this case? Is there any nice solutions that I could be pointed towards, since I'm not exactly sure what I'm looking for at this point? Thanks in advanced. I was just thinking, if I used separate sockets for sending and receiving data, would that reduce the "intensity" of this problem? currently, I have one socket(sockfd) to send data and receive data.
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,260
Rep Power: 5
![]() |
Another question with nothing to do with C++.
An obvious, if simplistic, approach would be to launch a separate thread (or process) for each connection. That way, only a particular thread will lock up rather than the whole server. You can also enforce some type of timeout policy (eg if a particular thread appears to have locked up, terminate it, but keep in mind that terminating threads does not release all resources used by the thread on some systems). Each thread could also impose some form of policy to slow down response to a user (eg if two packets arrive close together from the same, wait a specified period before responding to the second one). Without more specifics on what you're doing, it's difficult to give more useful advice. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|