Getting TCP Port status through C API


 
Thread Tools Search this Thread
Top Forums Programming Getting TCP Port status through C API
# 1  
Old 08-26-2010
Getting TCP Port status through C API

Does anyone know if there is a C API call to get the status of a TCP port? As opposed to running netstat and parsing the results. At the moment I have to attempt to bind() and pick up on the address in use error which isn't very elegant

Thanks

---------- Post updated at 10:42 AM ---------- Previous update was at 10:39 AM ----------

This is on Solaris 10. Unfortunately not Linux where I could have used the proc filesystem
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Tcp ip port open but no such process (merged: Release A Port)

i want to kill a tcp connection by killing its pid with netstat -an i got the tcp ip connection on port 5914 but when i type ps -a or ps-e there is not such process running on port 5914 is it possible that because i do not log on with proper user account i can not see that process running? (30 Replies)
Discussion started by: alinamadchian
30 Replies

2. Shell Programming and Scripting

Terminate processes for CLOSE_WAIT status of TCP

Hello Friends, First of all im sorry for spending extra space in DB of forum with this thread, i know there would be a solution if i kept searching, I need to terminate the process which causes CLOSE_WAIT status of TCP connection via port 8103: -bash-3.00$ netstat -na | grep 8103... (3 Replies)
Discussion started by: EAGL€
3 Replies

3. Programming

Using socket to test a TCP port

Hello, I'm trying to write a small c application to test a tcp port. This works fine for the most part but the default timeout on the connect is very long. I have been reading many posts but and it looks like I need to set the socket to be non-blocking and poll for a result. I have been totally... (2 Replies)
Discussion started by: tjones1105
2 Replies

4. IP Networking

TCP port numbers reused

Hello all, I am loosing the diameter connection between two servers and when the connection is trying to comes up again i see the following message in the tracer. and after 1 second the connection resets. As far i know the connection stay in state TIME_WAIT for a while(60 seconds in my... (1 Reply)
Discussion started by: @dagio
1 Replies

5. Shell Programming and Scripting

TCP port assignment

I have multiple processes running the same program on my linux machine. For each process I want to be able to use a unique (available) TCP port. I have thought of using netstat to check which ports are available for use however, the time-window between checking and selecting might expose some race... (1 Reply)
Discussion started by: timmylita
1 Replies

6. UNIX for Dummies Questions & Answers

close tcp port

Hello, I have a service running (ODBC) and every now and then it will hang and I will have to stop and restart the service. The problem is when I stop the service, it indeed stops the service, but netstat reports a tcp port still open with the fin_wait_2 status. Then I must close the client... (1 Reply)
Discussion started by: raidzero
1 Replies

7. Programming

TCP status question

There is a server and a client,when client send a message to server,server can send a reply to client. The status of server and client is ESTABLISHED.Then I halt the client,I find the server status is CLOSE_WAIT and the client status is FIN_WAIT_2. Many minutes passed,I find the the server status... (1 Reply)
Discussion started by: konvalo
1 Replies

8. Programming

How to check TCP server status

Please tell me according to C/C++ socket programming; how client can check whether server is running or not during TCP communication. (1 Reply)
Discussion started by: mansoorulhaq
1 Replies

9. UNIX for Dummies Questions & Answers

restrict tcp-port access

Hi Is there any way to restrict the TCP-IP port usage. I want to restrict TCP-IP port 1500/1550 to the oracle osuser. Tanks in advance. Remi (2 Replies)
Discussion started by: remivisser
2 Replies

10. IP Networking

tcp problem with port

I am trying to connect via DBACCESS and Informix server to a server on a different computer. When I execute the connect command from dbaccess I get the following message, Exec format error cannot bind a name to the port. As far as I know the port is not being used by another client. How... (1 Reply)
Discussion started by: lopez
1 Replies
Login or Register to Ask a Question
IP(3)							     Library Functions Manual							     IP(3)

NAME
ip - TCP, UDP, IL network protocols over IP SYNOPSIS
bind -a #Itcp /net bind -a #Iudp /net bind -a #Iil /net /net/tcp/clone /net/tcp/n /net/tcp/n/data /net/tcp/n/ctl /net/tcp/n/local /net/tcp/n/remote /net/tcp/n/status /net/tcp/n/listen ... DESCRIPTION
The IP device provides the interface for several protocols that run over IP on an Ethernet. TCP and UDP provide the standard Internet pro- tocols for reliable stream and unreliable datagram communication. IL provides a reliable datagram service for communication between Plan 9 machines. IL is the protocol of choice for most Plan 9 services. Each of the protocols is served by the IP device, which represents each connection by a set of device files. The top level directory of each protocol contains a clone file and subdirectories numbered from zero to the number of connections configured for this protocol. Opening the clone file reserves a connection. The file descriptor returned from the open(2) will point to the control file, ctl, of the newly allocated connection. Reading the ctl file returns a text string representing the number of the connection. Connections may be used either to listen for incoming calls or to initiate calls to other machines. A connection is controlled by writing text strings to the associated ctl file. After a connection has been established data may be read from and written to the data file. For the datagram services, IL and UDP, a read of less than the length of a datagram will cause the entire datagram to be consumed. Each write to the data file will send a single datagram on the network. The TCP protocol provides a stream connection that does not preserve read/write boundaries. Prior to sending data, remote and local addresses must be set for the connection. For outgoing calls the local port number will be allo- cated randomly if none is set. Addresses are set by writing control messages to the ctl file of the connection. The connection is not established until the data file is opened. For IL and TCP the process will block until the remote host has acknowledged the connection. UDP opens always succeed. The following control messages are supported: connect ipaddress!port[!r] Set the remote IP address and port number for the connection. If the r flag is supplied and no local address has been specified the system will allocate a restricted port number (less than 1024) for the connection to allow communication with Unix machines' login and exec services. disconnect (UDP only) Clear the remote address of a UDP connection. announce X X is a decimal port number or Set the local port number to X and accept calls to X. If X is accept calls for any port that no process has explicitly announced. The local IP address cannot be set. Announce fails if the connection is already announced or connnected. bind X X is a decimal port number or Set the local port number to X. This exists to support library emulation of BSD sockets and is not otherwise used. backlog n (IL and TCP only) Set the maximum number of pending requests for a given service to n. By default n is set to five. If more than n connections are pending, further requests for a service will be rejected. Port numbers must be in the range 1 to 32767. If a local port has not been announced prior to a connect a local port number will be allo- cated automatically. Local ports are allocated from 5000 up. Several files report the status of a connection. The remote and local files contain the IP address and port number for the remote and local side of the connection. The status file contains protocol-dependent information to help debug network connections. A process may accept incoming connections by calling open on the listen file. The open will block until a new connection request arrives. Then open will return an open file descriptor which points to the control file of the newly accepted connection. This procedure will accept all calls for the given protocol. SEE ALSO
listen(8), dial(2), ndb(6) SOURCE
/sys/src/9/port/devip.c /sys/src/9/port/stil.c /sys/src/9/port/stip.c /sys/src/9/port/tcp*.c IP(3)