Results 1 to 10 of 13
Hi,
According to the RFC 793 (TCP) the timeout factor in the TCP ping can be adjusted with the help of ‘timeout’ parameter with OPEN and SEND calls.
The format ...
- 04-24-2009 #1Just Joined!
- Join Date
- Apr 2009
- Posts
- 9
TCP Timeout
Hi,
According to the RFC 793 (TCP) the timeout factor in the TCP ping can be adjusted with the help of ‘timeout’ parameter with OPEN and SEND calls.
The format of these calls are as follows.
OPEN (local port, foreign socket, active/passive [, timeout] [, precedence]
[, security/compartment] [, options]) -> local connection name
SEND (local connection name, buffer address, byte
count, PUSH flag, URGENT flag [, timeout])
I want to know how can I use it in my application.
I am preparing a utility which will dows the TCP ping.
If someone can provode any sample code... It will be heartly welcomed.
Regards
Vishal
- 04-25-2009 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
In a C or C++ program, you would use the timeout in the select() or pselect() call. There is no timeout settings on open(), socket(), or send() functions in the C APIs. Are you familiar with C programming in general, and TCP/IP programming in C in particular? If not, then you have a pretty big learning curve to get up.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 04-25-2009 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
You can also do this sort of stuff with various scripting languages such as Perl and Python, or you can use something like Java. You would need to read the reference docs for those languages to determine how to accomplish your goal with regard to a "ping" clone.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 05-13-2009 #4Just Joined!
- Join Date
- May 2009
- Posts
- 4
Help on TCP IP Time Wait state!
Hi All!
In a tcp connection its a four way teardown. My question is when there is fin sent by the client for termination and client goes down abruptly. Now again a new connection is initiated from the same port but server now would have got a fin earlier for the same port and now getting syn packet for the same port. My question is will the server accept this and establish connection or it will not and discard this syn packet ?.
Thanks
Balaji
- 05-13-2009 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
I suppose the answer would have to be "it depends". If it is accepting connections on that port, then it depends upon whether it has the resources to handle another connection. The other one may still be "live" in its eyes - that is something for the programmer to decide. So, if it can handle another connection, then it will accept the request and open the session socket, otherwise it will reject it.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 05-13-2009 #6Just Joined!
- Join Date
- May 2009
- Posts
- 4
- 05-13-2009 #7Linux Guru
- Join Date
- Nov 2007
- Posts
- 1,695
No, the same port cannot be used. If the server closes down a TCP connection, the port goes into TCP_WAIT state. This is a pre-defined timeout that has to expire before the port is used again.
The "defacto" standard for the timeout is 240 sec. On high traffic machines that burn through many ports, this is commonly reduced to make ports available more quickly.
- 05-13-2009 #8Just Joined!
- Join Date
- May 2009
- Posts
- 4
- 05-13-2009 #9Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
It depends upon the server. The accept() function will take any number of connection requests on a port. If the server isn't using accept(), but some other method to accept (sic) incoming connections, then that's another story. The server typically uses accept() on a port to get connection requests, which returns a session socket, forks off a sub-process or thread to handle the session, and goes back to accepting more connections. By programmer specifications, I refer to the listen() function, which tells the TCP/IP stack how many active connections can be handled, or if it has received the connection socket, it can terminate it if necessary because of exhausted resources.
As for what the "standard" says, I'd have to reference my White Book for the RFC on that. No time right now. Do you have the DDN White Book? If so, let me know where it gets explicit about how a server handles connections. The protocols are pretty flexible in that regard, I think, as long as the state transitions are clear.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 05-13-2009 #10Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
This is for session ports, not for the port that is accepting connections. There is some misunderstanding here, I think. You are correct. The same connection port cannot be used until it is cleared/terminated. Servers typically use accept() for TCP stream connections, which returns a socket bound to another port, and it can receive any number of connection requests, with a backlog set by listen(). However, the server will not likely reuse a port that has a partially terminated connection. At least that has been my experience.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
