472,952 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,952 software developers and data experts.

Transfer socket connection between programs

Does anyone know any method to have one program, acting as a server
transfer a socket connection to another program? I looked into
transferring the connection via xml rpc to no avail. It seems to be a
problem of getting access to a programs private memory space and
giving another program access to that space.

Thanks in advance,
James Howard

Nov 12 '07 #1
7 2934
On 2007-11-12, JamesHoward <Ja************@gmail.comwrote:
Does anyone know any method to have one program, acting as a
server transfer a socket connection to another program?
The only way I know of is to use fork. When you fork a
process, all open file-descriptors (including network
connections) are inherited by the child.
I looked into transferring the connection via xml rpc to no
avail.
I've no idea how that could work (even in theory) on any OS
with which I'm familiar.
It seems to be a problem of getting access to a programs
private memory space and giving another program access to that
space.
Private memory has nothing to do with it. The connection is a
data structure that lives in kernel space, not in user space.
Even if you could grant another process access to your "private
memory space", it wouldn't help you "transfer a socket
connection", since that connection is something the OSes
manages.

--
Grant Edwards grante Yow! ! Everybody out of
at the GENETIC POOL!
visi.com
Nov 12 '07 #2
JamesHoward <Ja************@gmail.comwrites:
Does anyone know any method to have one program, acting as a server
transfer a socket connection to another program? I looked into
transferring the connection via xml rpc to no avail.
You have to use an out of band communication mechanism. On Linux this
is the SCM_RIGHTS ancillary message over Unix domain sockets. There
are similar things for Solaris and Windows. Unfortunately, Python
doesn't support any of them at the moment, but there's was once an RFE
waiting for a patch:

http://mail.python.org/pipermail/pyt...er/020431.html

Actually I'm having trouble finding the RFE mentioned any more, but it
it looks like Heiko Wundram did a patch in a different item:

http://bugs.python.org/issue1194378

See also:

http://bugs.python.org/issue1492240
Nov 12 '07 #3
On Nov 12, 12:50 pm, Grant Edwards <gra...@visi.comwrote:
On 2007-11-12, JamesHoward <James.w.How...@gmail.comwrote:
Does anyone know any method to have one program, acting as a
server transfer a socket connection to another program?

The only way I know of is to use fork. When you fork a
process, all open file-descriptors (including network
connections) are inherited by the child.
I looked into transferring the connection via xml rpc to no
avail.

I've no idea how that could work (even in theory) on any OS
with which I'm familiar.
It seems to be a problem of getting access to a programs
private memory space and giving another program access to that
space.

Private memory has nothing to do with it. The connection is a
data structure that lives in kernel space, not in user space.
Even if you could grant another process access to your "private
memory space", it wouldn't help you "transfer a socket
connection", since that connection is something the OSes
manages.

--
Grant Edwards grante Yow! ! Everybody out of
at the GENETIC POOL!
visi.com
Thanks Grant,

Does this mean that there is some way to transfer a pointer to that
kernel memory space from one program to another and have it be valid,
or is that kernel memory space protected and unusable from other
processes?
Nov 12 '07 #4
On 2007-11-12, JamesHoward <Ja************@gmail.comwrote:
>Private memory has nothing to do with it. The connection is a
data structure that lives in kernel space, not in user space.
Even if you could grant another process access to your "private
memory space", it wouldn't help you "transfer a socket
connection", since that connection is something the OSes
manages.
Does this mean that there is some way to transfer a pointer to that
kernel memory space from one program to another and have it be valid,
No.
or is that kernel memory space protected and unusable from other
processes?
On Linux (I'm not sure how it works on Windows), there is a
table of file descriptors that the kernel keeps for each
process. A table entry can be an open file on disk, a serial
port, a network connection, etc.

A file descriptor is just an index into that table. That table
can't be accessed by any other processes. When you fork a
process the new process inherits a copy of that table (and
therefore inherits any open network connections).

--
Grant Edwards grante Yow! I'm having an
at EMOTIONAL OUTBURST!! But,
visi.com uh, WHY is there a WAFFLE
in my PAJAMA POCKET??
Nov 12 '07 #5
JamesHoward wrote:
Does anyone know any method to have one program, acting as a server
transfer a socket connection to another program? I looked into
transferring the connection via xml rpc to no avail. It seems to be a
problem of getting access to a programs private memory space and
giving another program access to that space.
If you are using UNIX, you can create a pipe in the filesystem, and
connect I/O on both ends. Of course this is not the same, because - for
example - you cannot use setsockopt. But it works with already existing
processes very well, and usually you can setup socket options in your
server.

Under windows, I have no clue. It may be possible to use pipes under
Windows but I don't know how. You can also use other nasty techniques,
like loading a DLL into your "another program", then make a code hook
into your server. Brrrrrrr. :-) (Unstable, not portable even between
Windows versions...)

Regards,

Laszlo
Nov 12 '07 #6
JamesHoward napisa (a):
Does anyone know any method to have one program, acting as a server
transfer a socket connection to another program? I looked into
transferring the connection via xml rpc to no avail. It seems to be a
problem of getting access to a programs private memory space and
giving another program access to that space.

Thanks in advance,
James Howard
Under Windows you may want to use WSADuplicateSocket WinAPI function +
a named pipe (for example) to transfer the obtained socket data from
one process to the other.

Hope that helped,
Marek

Nov 12 '07 #7
On Nov 12, 1:41 pm, JamesHoward <James.w.How...@gmail.comwrote:
Does anyone know any method to have one program, acting as a server
transfer a socket connection to another program? I looked into
transferring the connection via xml rpc to no avail. It seems to be a
problem of getting access to a programs private memory space and
giving another program access to that space.

Thanks in advance,
James Howard
On Unix, you can use Unix Domain Sockets to pass file descriptors
between processes. You need to create a Unix Socket, then use sendmsg
and recvmsg to pass the file descriptor between processes.

Linux Application Development includes an example of how to do this in
section 16.4.6. The book is available through Amazon.com at
http://www.amazon.com/Linux-Applicat.../dp/0321219147

I'm sure you can find other examples on the internet to follow.

Hope this points you in the right direction,

--Nathan Davis

Nov 12 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: anuradha.k.r | last post by:
hi, i am writing a socket program in python,both client side and server side.I've written the client side which is working perfectly fine(checked it against server program written in C).but as for...
3
by: Thomas Hervé | last post by:
My problem is not really python specific but as I do my implementation in python I hope someone here can help me. I have two programs that talk through a socket. Here is the code : <server>...
11
by: Abhishek | last post by:
I have a problem transfering files using sockets from pocket pc(.net compact c#) to desktop(not using .net just mfc and sockets 2 API). The socket communication is not a issue and I am able to...
4
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
0
by: =?Utf-8?B?QWxwZXIgQUtDQVlPWg==?= | last post by:
Hello, First of all I wish you a good day. My help request is about .NET asynchrounus socket communication. I have developed Server-Client Windows Forms .NET applications in VC++ .NET v2003. I...
4
by: Andrew Jackson | last post by:
I am writing a newsgroup client. I have the protocol figured out. But I get slow transfer speeds off any of the network objects read the data from For example one of the commands for a news...
6
by: shelato | last post by:
Hi, I am able to open a socket connection to a micro controller, connected to a lynksys router, using visual basic code on a windows web site. Now I'm trying to open a socket connection using...
1
by: keksy | last post by:
Hi every1, I am writing a small client/server application and in it I want to send an image asynchronous from the client to the server through a TCP socket. I found an example code on the MSDN...
1
by: diegoblin | last post by:
Hi, i kind of new to java and i want to transfer a file between a server and a client. I know i have to use InputStream and OutputStream, but i don't know how to do it properly. So far i think i've...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.