Networking
I''m still writing on that little "I''m learning how to network" program I started some time ago. It''s somewhat getting better, but it''s got some strange behaviour:
I create a communications socket connected to a specific port (using socket(), bind(), listen()) and then accept() a connection on it. When the connection is closed, I close() the socket. Afterwards, I cannot restart the program for approximaely one minute because the network port I''m using still seems to be blocked. Is this normal behaviour that I just have to live with or do I do something wrong?
---
ls -lR|rm -rf /
(Best compression everywhere. Kids, don''t try this as root.)
This is intentional, check out rfc 793 and rfc 1122.TCP/IP goes into TIME_WAIT, where you cannot connect with the same 5-tuple for roughly 30-90 seconds.The 5-tuple is the result of...
the local host
the remote host
the local port
the remote port
the transport protocol
How you can remedy this is to not have your client connect on a pre-designated port (this is not a good thing to do in most cases anyway); you want to have the client send the connection request to a designated port, but not connect on it...Have your server open a listen socket (on your pre-designated port), when it recieves a connection request, your server creates a new socket (not on any specific port), and connect the incomming request to the new socket.
----------
meh
the local host
the remote host
the local port
the remote port
the transport protocol
How you can remedy this is to not have your client connect on a pre-designated port (this is not a good thing to do in most cases anyway); you want to have the client send the connection request to a designated port, but not connect on it...Have your server open a listen socket (on your pre-designated port), when it recieves a connection request, your server creates a new socket (not on any specific port), and connect the incomming request to the new socket.
----------
meh
----------meh
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement