1

Let's say our PC with IP 10.0.0.1 (local IP: 192.168.0.1) has an established connection on port 1001 to a server with IP 11.0.0.1 on port 1011. We can see this connection when we use the Netstat command:

TCP 192.168.0.1:1001 11.0.0.1:1011 ESTABLISHED

This connection was made by another program. Is it possible to programmatically access this existing socket and send data through it? It doesn't matter what language I have to use (preferably Java or .NET though).

Desired example:

Socket s = Socket.getEstablishedLocalConnection("11.0.0.1", 1001, 1011);
s.sendUrgentData(0);
Im2be
  • 53
  • 2
  • 4

1 Answers1

0

What OS are you using? I'm going to assume Windows from the Java/.Net comment.

This is not possible from typical UNIX-like operating systems (Linux, Mac OS X, iOS, etc.) The textbook solution would be to have one process open and "own and manage" the socket. It could then multiplex output from multiple other processes. Those other processes would in turn have to supply their output to the socket-controlling process via some agreed-upon IPC mechanism: another socket connection, a unix domain socket, a unix FIFO, SysV IPC, writes to shared memory, writes to a shared file, etc.

Flortify
  • 619
  • 5
  • 15