Operating System - Linux
1833044 Members
2574 Online
110049 Solutions
New Discussion

Re: How to send data through already existing sockets

 
Satishrao84
Occasional Contributor

How to send data through already existing sockets

Hi,
Is there a way to send data through sockets already created by another VUser, so as to minimize the number of connections made to the target server?

Thanks,
Satish
2 REPLIES 2
Matti_Kurkela
Honored Contributor

Re: How to send data through already existing sockets

What is a VUser? Are you talking about some specific application?

Generally you cannot just hijack the sockets off another process, since a) the OS will not allow that, and b) you don't know what the other process was doing with it.

If the original owner was in the middle of sending some request while you somehow managed to grab the socket to send your own request, the target server would see the two requests jumbled together into an unrecognizable mess. A typical result would be the server sending some sort of a "protocol error detected" response and/or closing the connection at the server end.

So, if two or more processes need to use the same socket, some sort of coordination scheme is required. The processes will either need to communicate with each other using some Inter-Process Communication method that allows passing file descriptors/sockets from one process to another, or one of the processes needs to be acting as a proxy for the others. This would be rather specific to whatever protocol your target server is using and what your processes are designed to do, so it's likely you would have to design and program it yourself.

Also, the network protocol used by the target server is important. If the protocol is designed to accept only one request per connection, you cannot benefit much from sharing the sockets, as each socket must be closed anyway after the first request is made through it.

MK
MK
Reiner  Rottmann
Frequent Advisor

Re: How to send data through already existing sockets

If you want to minimize the connections between a server, how about using a SSH tunnel?