LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2006, 07:49 AM   #1
amit.saha
LQ Newbie
 
Registered: Jun 2006
Posts: 1

Rep: Reputation: 0
Get the current TCP/UDP conenction status


How can i get the current state of the TCP connection ( ESTABLISHED,SYN_WAIT, etc) thorugh C?
 
Old 06-23-2006, 12:49 AM   #2
prozac
Member
 
Registered: Oct 2005
Location: Australia
Distribution: slackware 12.1
Posts: 753

Rep: Reputation: 32
through C?
 
Old 06-23-2006, 01:46 AM   #3
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,141

Rep: Reputation: 168Reputation: 168
Have you looked at iptstate at http://www.phildev.net/iptstate/? It might give you some useful information.
 
Old 06-23-2006, 01:57 AM   #4
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
One method is to use procfs :

Open /proc/net/tcp and sscanf on it.
The first line is the header, st being the state, local_address is of the form ip_in_hex:port_in_hex.

ESTABLISHED=1
SYN_SENT=2
SYN_RECV=3
FIN_WAIT1=4
FIN_WAIT2=5
TIME_WAIT=6
CLOSE=7
CLOSE_WAIT=8
LAST_ACK=9
LISTEN=10
CLOSING=11

Should be sufficient..

Last edited by nx5000; 06-23-2006 at 01:58 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
About TCP / UDP shipon_97 Linux - Newbie 5 06-24-2012 06:22 PM
TCP/UDP Confusion blackhole123 Linux - Networking 1 11-15-2005 03:46 AM
tcp/udp and c++ Kroenecker Programming 1 05-10-2005 11:56 AM
UDP over TCP The_Nerd Programming 7 07-21-2004 09:45 PM
TCP vs. UDP mikeshn Linux - Networking 5 05-17-2003 04:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration