09-22-2010
I modified my code to use poll to wait for data from sockets and commented out the ioctl() call and added poll() calls so that I wouldn't have to worry about waiting indefinitely on readable data to show up on the port which appears to have fixed my problem!
Thank you,
Brandon
---------- Post updated at 04:15 PM ---------- Previous update was at 02:12 PM ----------
Removing ioctl didn't fix the problem, the data just makes it to the port randomly now..
I see something on Wikipedia under TCP about close() on a port with data still in the queue, but it doesn't have a reference to how to fix the issue (I would post a link, but I haven't posted 5 articles yet!)
10 More Discussions You Might Find Interesting
1. IP Networking
:cool:
I want to use 2 tcp applications in SCO 5.05 senerio I am using
VisionFS 3.1 and I need to set it up as a secondary tcp app. I follow the profeditoir and change the tcp port from the primary port (139) to any other number below port 1024 and then restart the VisionFS server it is still... (2 Replies)
Discussion started by: lanman
2 Replies
2. UNIX for Dummies Questions & Answers
If I do a netstat -a I can see all the sockets currently open, is there a way that I can tell which application is holding open these sockets ? (3 Replies)
Discussion started by: murphyboy
3 Replies
3. UNIX for Dummies Questions & Answers
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
4. Programming
Hi all,
I'm writing a socket program which sends a structure from one machine to another. When I run my client first time it runs well, however after the first time I couldn't receive all the data inside the structure (it is like, half of the array is received and the other half is not set). I... (1 Reply)
Discussion started by: SaTYR
1 Replies
5. Programming
Hello. I would like to know how to close an existing tcp socket. I have read some stuff and learned how to create a socket and then close it but have not found anything about how to close an existing tcp socket created by another application. The situation is this: I have an ODBC server running and... (6 Replies)
Discussion started by: raidzero
6 Replies
6. Solaris
Hi,
I use solaris Unix .
I find there is some problem in application and it generate many "close-wait" tcp connect and stay in the server . it is generate by process id 7740
root@XX # netstat -an | grep CLOSE_WAIT | wc -l
285
root@XX # netstat -an | grep CLOSE_WAIT
10.158.35.4.34805 ... (2 Replies)
Discussion started by: abcdef
2 Replies
7. Programming
can someone provide an example, where if the parent process quits for any reason, then the child process will also close? (3 Replies)
Discussion started by: omega666
3 Replies
8. IP Networking
Hello All,
I am very new to socket programming and client server architecture. I have to write a client which will send some data to server and server will display it on its console. I am ready with both client and server but my problem is with packetizing of data --
I have... (1 Reply)
Discussion started by: anand.shah
1 Replies
9. Shell Programming and Scripting
Hi
I want to write a script that will back up one directory if a certain application launches and then backs up another directory if that same application is closed down.
NFI where to start. It seems like cron isn't the tool for this because that is time based. I'm thinking I need... (6 Replies)
Discussion started by: zorrokan
6 Replies
10. UNIX for Advanced & Expert Users
Good morning, I need your help please
After Restarting Aps or connection, these are connections
tcp 0 0 10.80.1.26.57597 10.81.248.79.53008 ESTABLISHED
tcp 0 47 10.80.1.26.57607 10.81.248.79.53008 ESTABLISHED
tcp 0 0 ... (4 Replies)
Discussion started by: alexcol
4 Replies
TCP(4P) TCP(4P)
NAME
tcp - Internet Transmission Control Protocol
SYNOPSIS
#include <sys/socket.h>
#include <netinet/in.h>
s = socket(AF_INET, SOCK_STREAM, 0);
DESCRIPTION
The TCP protocol provides reliable, flow-controlled, two-way transmission of data. It is a byte-stream protocol used to support the
SOCK_STREAM abstraction. TCP uses the standard Internet address format and, in addition, provides a per-host collection of "port
addresses". Thus, each address is composed of an Internet address specifying the host and network, with a specific TCP port on the host
identifying the peer entity.
Sockets utilizing the tcp protocol are either "active" or "passive". Active sockets initiate connections to passive sockets. By default
TCP sockets are created active; to create a passive socket the listen(2) system call must be used after binding the socket with the bind(2)
system call. Only passive sockets may use the accept(2) call to accept incoming connections. Only active sockets may use the connect(2)
call to initiate connections.
Passive sockets may "underspecify" their location to match incoming connection requests from multiple networks. This technique, termed
"wildcard addressing", allows a single server to provide service to clients on multiple networks. To create a socket which listens on all
networks, the Internet address INADDR_ANY must be bound. The TCP port may still be specified at this time; if the port is not specified
the system will assign one. Once a connection has been established the socket's address is fixed by the peer entity's location. The
address assigned the socket is the address associated with the network interface through which packets are being transmitted and received.
Normally this address corresponds to the peer entity's network.
TCP supports one socket option which is set with setsockopt(2) and tested with getsockopt(2). Under most circumstances, TCP sends data
when it is presented; when outstanding data has not yet been acknowledged, it gathers small amounts of output to be sent in a single packet
once an acknowledgement is received. For a small number of clients, such as window systems that send a stream of mouse events which
receive no replies, this packetization may cause significant delays. Therefore, TCP provides a boolean option, TCP_NODELAY (from
<netinet/tcp.h>, to defeat this algorithm. The option level for the setsockopt call is the protocol number for TCP, available from getpro-
tobyname(3N).
Options at the IP transport level may be used with TCP; see ip(4P). Incoming connection requests that are source-routed are noted, and the
reverse source route is used in responding.
DIAGNOSTICS
A socket operation may fail with one of the following errors returned:
[EISCONN] when trying to establish a connection on a socket which already has one;
[ENOBUFS] when the system runs out of memory for an internal data structure;
[ETIMEDOUT] when a connection was dropped due to excessive retransmissions;
[ECONNRESET] when the remote peer forces the connection to be closed;
[ECONNREFUSED] when the remote peer actively refuses connection establishment (usually because no process is listening to the port);
[EADDRINUSE] when an attempt is made to create a socket with a port which has already been allocated;
[EADDRNOTAVAIL] when an attempt is made to create a socket with a network address for which no network interface exists.
SEE ALSO
getsockopt(2), socket(2), intro(4N), inet(4F), ip(4P)
4.2 Berkeley Distribution May 16, 1986 TCP(4P)