Solved

recv() and send() is blocking

Posted on 2011-09-21
32
688 Views
Last Modified: 2012-06-27
Hello
Our application is using port 1723 to run socket api on hpux  send() and recv()
both end points are on the same machine.
After we start the application, situation is:
# netstat -a | grep 1723
tcp        0      0  localhost.1723         localhost.62687         ESTABLISHED
tcp        0      0  localhost.62951        localhost.1723          ESTABLISHED
tcp        0      0  localhost.61263        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.61262         ESTABLISHED
tcp        0      0  localhost.1723         localhost.61268         ESTABLISHED
tcp        0      0  localhost.62859        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.62818         ESTABLISHED
tcp        0      0  localhost.62722        localhost.1723          ESTABLISHED
tcp        0      0  localhost.62990        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.63101         ESTABLISHED
tcp        0      0  localhost.1723         localhost.62859         ESTABLISHED
tcp        0      0  localhost.61268        localhost.1723          ESTABLISHED
tcp        0      0  localhost.63101        localhost.1723          ESTABLISHED
tcp        0      0  localhost.61262        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.61248         ESTABLISHED
tcp        0      0  localhost.1723         *.*                     LISTEN
tcp        0      0  localhost.62687        localhost.1723          ESTABLISHED
tcp        0      0  localhost.61248        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.61251         ESTABLISHED
tcp        0      0  localhost.1723         localhost.62990         ESTABLISHED
tcp        0      0  localhost.61251        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.61263         ESTABLISHED
tcp        0      0  localhost.1723         localhost.62722         ESTABLISHED
tcp        0      0  localhost.62818        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.61277         ESTABLISHED
tcp        0      0  localhost.61277        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.62951         ESTABLISHED

After giving input in runtime and then socket calls send() and recv() are stil increased

bytes_sent = send(sock_fd, tmp, message_l - total_bytes_sent, flags );
bytes_read = recv(sock_fd, tmp, buffer_l - total_bytes_read, flags);

We see huge number(1743669) of above 2 calls from a particular process on sock_fd=4.

After 30 minutes, we see the below, By this time, input processing should be completed:

# netstat -a | grep 1723
tcp        0      0  localhost.1723         localhost.62986         CLOSE_WAIT
tcp        0      0  localhost.63080        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62985        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63040        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63075         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62942         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62865         CLOSE_WAIT
tcp        0      0  localhost.63029        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62893        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62923        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62843         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62964         CLOSE_WAIT
tcp        0      0  localhost.62953        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62948         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62851         CLOSE_WAIT
tcp        0      0  localhost.62979        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62932         CLOSE_WAIT
tcp        0      0  localhost.62909        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62964        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62988         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62955         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63085         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62969         CLOSE_WAIT
tcp        0      0  localhost.63006        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63040         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62931         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62860         CLOSE_WAIT
tcp        0      0  localhost.61263        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.62997         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62947         CLOSE_WAIT
tcp        0      0  localhost.62954        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.61262         ESTABLISHED
tcp        0      0  localhost.63046        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63045         CLOSE_WAIT
tcp        0      0  localhost.62835        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63023         CLOSE_WAIT
tcp        0      0  localhost.62879        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.61268         ESTABLISHED
tcp        0      0  localhost.1723         localhost.62879         CLOSE_WAIT
tcp        0      0  localhost.62999        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62987        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62929         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62953         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62928         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62885         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62921         CLOSE_WAIT
tcp        0      0  localhost.63085        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62847         CLOSE_WAIT
tcp        0      0  localhost.62988        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62847        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62850         CLOSE_WAIT
tcp        0      0  localhost.62866        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62872        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63006         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62954         CLOSE_WAIT
tcp        0      0  localhost.63075        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62835         CLOSE_WAIT
tcp        0      0  localhost.61268        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.63001         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62872         CLOSE_WAIT
tcp        0      0  localhost.62997        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.61262        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.62985         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62923         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62999         CLOSE_WAIT
tcp        0      0  localhost.62865        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62998        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62980        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63035        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.61248         ESTABLISHED
tcp        0      0  localhost.1723         *.*                     LISTEN
tcp        0      0  localhost.1723         localhost.62996         CLOSE_WAIT
tcp        0      0  localhost.62922        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63018         CLOSE_WAIT
tcp        0      0  localhost.62851        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62998         CLOSE_WAIT
tcp        0      0  localhost.62921        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62986        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62957        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62957         CLOSE_WAIT
tcp        0      0  localhost.62991        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63018        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62932        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63069        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.61248        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.62890         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63046         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62866         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62922         CLOSE_WAIT
tcp        0      0  localhost.62860        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62929        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62996        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.61251         ESTABLISHED
tcp        0      0  localhost.62850        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63080         CLOSE_WAIT
tcp        0      0  localhost.63045        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62890        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62930        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63001        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62980         CLOSE_WAIT
tcp        0      0  localhost.62947        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62987         CLOSE_WAIT
tcp        0      0  localhost.62959        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62906        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63024        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62958         CLOSE_WAIT
tcp        0      0  localhost.62934        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62868         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62970         CLOSE_WAIT
tcp        0      0  localhost.62948        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62930         CLOSE_WAIT
tcp        0      0  localhost.62969        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62941        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.61251        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.61263         ESTABLISHED
tcp        0      0  localhost.1723         localhost.62906         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62979         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63058         CLOSE_WAIT
tcp        0      0  localhost.62905        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62959         CLOSE_WAIT
tcp        0      0  localhost.63064        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63058        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62991         CLOSE_WAIT
tcp        0      0  localhost.62868        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62905         CLOSE_WAIT
tcp        0      0  localhost.62885        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63017        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62893         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.61277         ESTABLISHED
tcp        0      0  localhost.62970        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.61277        localhost.1723          ESTABLISHED
tcp        0      0  localhost.62955        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62931        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62909         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62934         CLOSE_WAIT
tcp        0      0  localhost.63023        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63064         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63069         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63017         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63029         CLOSE_WAIT
tcp        0      0  localhost.62942        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63035         CLOSE_WAIT
tcp        0      0  localhost.62958        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62928        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62843        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62941         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63024         CLOSE_WAIT

Do you think we need to something before calling recv() or send()?

Sham




0
Comment
Question by:mohet01
  • 19
  • 8
  • 4
  • +1
32 Comments
 

Author Comment

by:mohet01
ID: 36573017
What exactly could be the problem that
# netstat -a | grep 1723
is showing the above output after 30 minutes?


0
 

Author Comment

by:mohet01
ID: 36573052
Afer 1 hour below is the output:
# netstat -a | grep 1723
tcp        0      0  localhost.1723         localhost.62986         CLOSE_WAIT
tcp        0      0  localhost.63080        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62985        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63040        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63075         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62942         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62865         CLOSE_WAIT
tcp        0      0  localhost.63029        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62893        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62923        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62843         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62964         CLOSE_WAIT
tcp        0      0  localhost.62953        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62948         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62851         CLOSE_WAIT
tcp        0      0  localhost.62979        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62932         CLOSE_WAIT
tcp        0      0  localhost.62909        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62964        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62988         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62955         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63085         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62969         CLOSE_WAIT
tcp        0      0  localhost.63006        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63040         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62931         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62860         CLOSE_WAIT
tcp        0      0  localhost.61263        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.62997         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62947         CLOSE_WAIT
tcp        0      0  localhost.62954        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.61262         ESTABLISHED
tcp        0      0  localhost.63046        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63045         CLOSE_WAIT
tcp        0      0  localhost.62835        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63023         CLOSE_WAIT
tcp        0      0  localhost.62879        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.61268         ESTABLISHED
tcp        0      0  localhost.1723         localhost.62879         CLOSE_WAIT
tcp        0      0  localhost.62999        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62987        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62929         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62953         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62928         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62885         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62921         CLOSE_WAIT
tcp        0      0  localhost.63085        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62847         CLOSE_WAIT
tcp        0      0  localhost.62988        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62847        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62850         CLOSE_WAIT
tcp        0      0  localhost.62866        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62872        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63006         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62954         CLOSE_WAIT
tcp        0      0  localhost.63075        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62835         CLOSE_WAIT
tcp        0      0  localhost.61268        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.63001         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62872         CLOSE_WAIT
tcp        0      0  localhost.62997        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.61262        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.62985         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62923         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62999         CLOSE_WAIT
tcp        0      0  localhost.62865        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62998        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62980        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63035        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.61248         ESTABLISHED
tcp        0      0  localhost.1723         *.*                     LISTEN
tcp        0      0  localhost.1723         localhost.62996         CLOSE_WAIT
tcp        0      0  localhost.62922        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63018         CLOSE_WAIT
tcp        0      0  localhost.62851        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62998         CLOSE_WAIT
tcp        0      0  localhost.62921        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62986        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62957        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62957         CLOSE_WAIT
tcp        0      0  localhost.62991        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63018        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62932        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63069        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.61248        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.62890         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63046         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62866         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62922         CLOSE_WAIT
tcp        0      0  localhost.62860        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62929        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62996        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.61251         ESTABLISHED
tcp        0      0  localhost.62850        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63080         CLOSE_WAIT
tcp        0      0  localhost.63045        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62890        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62930        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63001        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62980         CLOSE_WAIT
tcp        0      0  localhost.62947        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62987         CLOSE_WAIT
tcp        0      0  localhost.62959        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62906        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63024        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62958         CLOSE_WAIT
tcp        0      0  localhost.62934        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62868         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62970         CLOSE_WAIT
tcp        0      0  localhost.62948        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62930         CLOSE_WAIT
tcp        0      0  localhost.62969        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62941        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.61251        localhost.1723          ESTABLISHED
tcp        0      0  localhost.1723         localhost.61263         ESTABLISHED
tcp        0      0  localhost.1723         localhost.62906         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62979         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63058         CLOSE_WAIT
tcp        0      0  localhost.62905        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62959         CLOSE_WAIT
tcp        0      0  localhost.63064        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63058        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62991         CLOSE_WAIT
tcp        0      0  localhost.62868        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62905         CLOSE_WAIT
tcp        0      0  localhost.62885        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.63017        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62893         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.61277         ESTABLISHED
tcp        0      0  localhost.62970        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.61277        localhost.1723          ESTABLISHED
tcp        0      0  localhost.62955        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62931        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62909         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.62934         CLOSE_WAIT
tcp        0      0  localhost.63023        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63064         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63069         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63017         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63029         CLOSE_WAIT
tcp        0      0  localhost.62942        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.63035         CLOSE_WAIT
tcp        0      0  localhost.62958        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62928        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.62843        localhost.1723          FIN_WAIT_2
tcp        0      0  localhost.1723         localhost.62941         CLOSE_WAIT
tcp        0      0  localhost.1723         localhost.63024         CLOSE_WAIT

0
 
LVL 3

Expert Comment

by:paradox_cla
ID: 36573084
The most likely application does not close open sockets.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 36573569
What about the netstat output don't you like ?

Is it the amount of connections ?

Or the fact that they end up in a CLOSE_WAIT or FIN_WAIT_2 state ?
0
 
LVL 12

Expert Comment

by:HappyCactus
ID: 36579409
the output are "dangling" sockets.
Use shutdown() before close() when closing the connection or the application.

man 2 shutdown
NAME
       shutdown - shut down part of a full-duplex connection

SYNOPSIS
       #include <sys/socket.h>

       int shutdown(int sockfd, int how);

DESCRIPTION
       The  shutdown()  call causes all or part of a full-duplex connection on the socket associated with sockfd to
       be shut down.  If how is SHUT_RD, further receptions will be disallowed.  If how is SHUT_WR, further  trans-
       missions will be disallowed.  If how is SHUT_RDWR, further receptions and transmissions will be disallowed.

Open in new window

0
 

Author Comment

by:mohet01
ID: 36719539
hello infinity
The port 1723 is ending up in closewait or finwait.
yes it is the number of send and recv per unit time
Sham
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 36812950
>> yes it is the number of send and recv per unit time

Are you implying that you make a new connection for every send/recv you do ?

Is that intentional/necessary ?
Are you properly closing the connection and cleaning up once the send/recv is done ?
0
 

Author Comment

by:mohet01
ID: 36813753
here is the answer
port number is 1723 used, multiple apps are running the below flow on same port.

=============================
CciInit: Entered with [CAI.SDK57e2-1][CAI.SDK57e2-1].
tc_sendMessageToProxy: proxy sock is -1.
tc_sendMessageToProxy: ERROR Not connected to proxy server.
tc_sendCmdblkToProxy: Establishing connection to server.
tc_openProxySocket: Entered
tc_connectToProxy -> getaddrinfo for localhost and TC_TCP_SERVNAME failed with [service not supported for socket type]
tc_connectToProxy -> getaddrinfo for ::1 and TC_TCP_SERVNAME failed with [service not supported for socket type]
tc_connectToProxy -> getaddrinfo failed for 127.0.0.1 and TC_TCP_SERVNAME with [service not supported for socket type]
verifyandconnect(): Entered verifyandconnect()
verifyandconnect(): Using AF_INET
verifyandconnect(): Succesful connection; returning TC_TCP_SUCCESS
tc_connectToProxy: leaving with socket=<14> rc=<0>.
tc_sendCmdblkToProxy: Established connection to proxy.
tc_sendMessageToProxy: proxy sock is 14.
tc_tcpSendMessageBlock: Entered socket=<14> message_p=<0x64103f78> message_l=<12> flags=<0>.
tc_tcpSendMessageBlock: Leaving total_bytes_sent=<12> rc=<0>.
tc_readMessageFromProxy: proxy sock is 14.
tc_tcpReadMessageBlock Entered socket<14> buffer_p<0x64103f88> buffer_l<60> flags<0x0>.
tc_tcpSocketSelect: Entered socket_fd=<14> timeout=<30> flag=<1>.
tc_tcpSocketSelect: select is for read.
tc_tcpSocketSelect: tv_sec=<30> tv_usec=<0>.
tc_tcpSocketSelect: before select.
tc_tcpSocketSelect: select returned numfds=<0> difftime=<1678541126>.
tc_tcpSocketSelect: select timed out.
tc_tcpSocketSelect: leaving with rc=<3>.
tc_tcpReadMessageBlock leaving with total_bytes_read=<0> rc=<1>.
tc_tcpReadMessageBlock: Closing client connection socket<14>.
tc_tcp_closeConnectionToProxy: Entered.
tc_tcp_closeConnectionToProxy: Leaving with rc=<0>.
CciInit: ERROR RPC Init call failed. process id=<22498>
tc_disconnectFromProxy: ERROR not connected to proxy server.
CciInit: Leaving with rc=<16>.
==================================


Sham
0
 

Author Comment

by:mohet01
ID: 36813757
netstat -p tcp 1723
tcp:
        594006 packets sent
                203442 data packets (28208633 bytes)
                5 data packets (2324 bytes) retransmitted
                189412 ack-only packets (36145 delayed)
                0 URG only packets
                0 window probe packets
                12 window update packets
                201152 control packets
        591573 packets received
                263024 acks (for 28346549 bytes)
                2 duplicate acks
                0 acks for unsent data
                196095 packets (18798516 bytes) received in-sequence
                0 completely duplicate packets (0 bytes)
                0 packets with some dup data (0 bytes duped)
                23 out of order packets (1158 bytes)
                0 packets (0 bytes) of data after window
                0 window probes
                2949 window update packets
                64 packets received after close
                0 segments discarded for bad checksum
                0 bad TCP segments dropped due to state change
        16621 connection requests
        17609 connection accepts
        34230 connections established (including accepts)
        45670 connections closed (including 13646 drops)
        11 embryonic connections dropped
        109954 segments updated rtt (of 109954 attempts)
        5 retransmit timeouts
                0 connections dropped by rexmit timeout
        0 persist timeouts
        134764 keepalive timeouts
                134759 keepalive probes sent
                0 connections dropped by keepalive
        0 connect requests dropped due to full queue
        138 connect requests dropped due to no listener
        0 suspect connect requests dropped due to aging
        0 suspect connect requests dropped due to rate
0
 

Author Comment

by:mohet01
ID: 36813764
After we see this problem,
this is the status
# netstat -a | grep CLOSE_WAI | wc -l
2096
# netstat -a | grep 1723 | grep CLOSE_WAI | wc -l
2096
# netstat -a | grep 1723 | grep FIN_WAI | wc -l
2096
0
 
LVL 12

Expert Comment

by:HappyCactus
ID: 36813775
Do you close the socket by first calling to shutdown? Both in server and in client side?
0
 

Author Comment

by:mohet01
ID: 36813995
yes we call shutdown first

void tc_closeClientConnection(int sock_fd)
{
  shutdown(sock_fd, 2);
  close(sock_fd);
}
0
 

Author Comment

by:mohet01
ID: 36814000
my server update is for server side
0
 

Author Comment

by:mohet01
ID: 36814004
on client side we do

int tc_tcp_closeConnectionToProxy(void)
{
  int rc = 0;
  if(close(TC_TCP_ProxySocket) == -1)
  {
    BPRINTF("tc_tcp_closeConnectionToProxy: close failed, errno=<%d>.\n", errno);
    rc = -1;
  }
  TC_TCP_ProxySocket = -1;
  //GlobalInitCount = 0;

  return rc;
}

0
 
LVL 12

Expert Comment

by:HappyCactus
ID: 36814017
So you don't call shutdown on the client side?
this is the cause of your problem.
0
 

Author Comment

by:mohet01
ID: 36814055
On client side after send() or recv() the flow is like this:

1) if the send() or recv() is successful, we only run close() on sockfd

2) if the send() or recv() fails, then we run
   close()  on sockfd
   and
then also run
shutdown() and close()  on sockfd.

Do you think this is the problem? If yes, why?
Sham


Sham


0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 12

Expert Comment

by:HappyCactus
ID: 36814081
Because shutdown must be called _before_ close().

http://linux.die.net/man/3/shutdown

0
 

Author Comment

by:mohet01
ID: 36814135
ok let me check this in my code
0
 

Author Comment

by:mohet01
ID: 36814156
canu show me the link, which says that,
shutdown() should be called before close()
?
0
 
LVL 12

Expert Comment

by:HappyCactus
ID: 36814172
The fd must be a valid file descriptor, and close() invalidates the fd.


http://linux.die.net/man/3/shutdown

0
 

Author Comment

by:mohet01
ID: 36814325
am anyways checking your point, but what i feel is
server is in CLOSE-WAIT state
client is in FIN-WAIT-2 state.

So, i think the problem is something else

screenshot will tell you, where exactly we are blocked
 tcp-close
0
 

Author Comment

by:mohet01
ID: 36814456
it is not working
0
 

Author Comment

by:mohet01
ID: 36814493
so the client port 1723 is blocked in FIN-WAIT-2 state
server port 1723 is blocked in CLOSE_WAIT state.
Why do you think this happens?
0
 
LVL 12

Expert Comment

by:HappyCactus
ID: 36814880
Can you post some code about the reading/writing loop of the server and client?
Can you take a snapshot of the tcp packets flow, for example by using a packet sniffer?
0
 
LVL 12

Expert Comment

by:HappyCactus
ID: 36814893
See this table: http://www.tcpipguide.com/free/t_TCPConnectionTermination-2.htm
your application is stuck at the 3rd line. As you can see, "The server waits for the application process on its end to signal that it is ready to close".
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 36815379
>> So you don't call shutdown on the client side?
>> this is the cause of your problem.

shutdown doesn't HAVE to be called. It's optional. A single close is sufficient to properly close the socket.

The problem in this case is on the server side : it doesn't properly close its end of the connection. You need to make sure that the server side calls close when appropriate.
0
 

Author Comment

by:mohet01
ID: 36890065
Hello Infinity
"The problem in this case is on the server side " I agree with this.

But i did not understand the point about closing the socket on server side.
"You need to make sure that the server side calls close when appropriate. "

As per socket programming, if client closes the socket, Does server needs to perform something? I think it is TCP which needs to handle.


Sham


0
 

Author Comment

by:mohet01
ID: 36890070
Hello infinity
One important update is, May be, I was not handling close of socket on client side properly.
Now after the changes, I see port status on TIME_WAIT state.

# netstat -a | grep 1723
tcp        0      0  localhost.1723         localhost.60480         TIME_WAIT
tcp        0      0  localhost.1723         localhost.60481         TIME_WAIT
tcp        0      0  localhost.1723         localhost.60482         TIME_WAIT
tcp        0      0  localhost.60455        localhost.1723          TIME_WAIT
tcp        0      0  localhost.60457        localhost.1723          TIME_WAIT
tcp        0      0  localhost.60458        localhost.1723          TIME_WAIT
tcp        0      0  localhost.60459        localhost.1723          TIME_WAIT
tcp        0      0  localhost.60460        localhost.1723          TIME_WAIT
tcp        0      0  localhost.60461        localhost.1723          TIME_WAIT
tcp        0      0  localhost.60462        localhost.1723          TIME_WAIT


Sham

0
 
LVL 12

Expert Comment

by:HappyCactus
ID: 36890232
And what is your changes?

TIME_WAIT is not a problem, they do not eat resources.
0
 

Author Comment

by:mohet01
ID: 36890241
changes are,
when the send() and recv() is successfull, we were actually not closing socket.
Incase of send() and recv() in failure, we were only closing sockets.
so we ran follwoing in send/recv success case.
1) shutdown(,)
2) close()


Sham

0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 500 total points
ID: 36890248
>> As per socket programming, if client closes the socket, Does server needs to perform something?

Yes, it needs to close its end of the socket.


>> I think it is TCP which needs to handle.

The TCP stack will finalize the connection for you, but it can only do that when you tell it it's ok to do it. And you do that by calling close on the socket.
0
 

Author Closing Comment

by:mohet01
ID: 36947004
thanx
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Network ports are the threads that hold network communication together. They are an essential part of networking that can be easily ignore or misunderstood, my goals is to show those who don't have a strong network foundation how network ports opera…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now