synchronizing endpoints of a socket

synchronizing endpoints of a socket

Post by Paul Mackl » Wed, 26 Jan 1994 02:01:41

What is the best strategy for synchronizing socket endpoints
on a Stream socket? For example, I have 2 process communicating
via a Stream socket, if one is always writing a 1024 byte
structure onto the socket, how can I guarantee tht the process
reading from the socket will, not only get 1024 bytes, but get
the proper 1024 bytes.

Paul Mackles

Paul Mackles


1. TCP socket endpoints mystery


My understanding about a TCP connection was that as long as the endpoints
( end1 IP, end1 port, end2 IP, end2 port. ) are unique, the connection is
unique. Or in other words given 2 endpoints, there can only be one
connection between them.

But while looking at some processes, I saw that sometimes there are more
than one connection established between the same endpoints
Eg : -

quark:/home/sony>lsof -iTCP:49024
ipmhd     2095   root  257u  IPv4 0x30005de9340  0t10996  TCP
quark:999->quark:49024 (ESTABLISHED)
ideasLog 11696   netx    7u  IPv4 0x30004e642d8   0t5452  TCP
quark:49024->quark:999 (ESTABLISHED)
oracle   11705 oracle    7u  IPv4 0x30004e642d8   0t5452  TCP
quark:49024->quark:999 (ESTABLISHED)

quark:/home/sony>ps -ef|egrep "11696|11705"
 sony 13222  8528  0 11:53:18 pts/21   0:00 egrep 11696|11705
    netx 11696     1  0 11:21:28 ?        0:02 ideasLog -s nms50
  oracle 11705 11696  0 11:21:30 ?        0:01 oraclenms

In this case netx has obviously fork() ed amd exec() ed oracle after the
connection has been established.

This brings up these questions..
1. What happens when a process fork() s after a connection has been
established ( accept() or connect() ). Who will get the futher packets. Hmm
just now I realised that this is exactly the case with the conventional
forking cuncurrent servers. In this case, did it work because, only the
child did a read(). What would have happened if the parent also did a read
on the same socket.

2. Is there any other way that this kind of situation arise, without a


2. TLI/XTI interface on linux question

3. Endpoint managment with sockets

4. Boot/Root rescue floppy problem (Bootdisk HOWTO)

5. Synchronizing sockets and message queues

6. How to setup a dumb terminal as console

7. Sockets sockets and more sockets

8. Socket, Socket, whose got the socket?

9. Socket, socket, who's got the socket?

10. Sockets sockets and more sockets

11. UHCI halts endpoint on control stalls: seems wrong

12. problem: Transport endpoint is not connected