Networking Forums

Networking Forums > Computer Networking > Linux Networking > sending socket descriptor to another pid

Reply
Thread Tools Display Modes

sending socket descriptor to another pid

 
 
Beagle
Guest
Posts: n/a

 
      07-08-2008, 04:30 AM
Folks,

Socket(2) returns a file descriptor, used to send, write or read data
from the socket. A process calling socket can successfully create the
socket. I found there is a way to send the socket file descriptor to
another process and be able to read and write data as if it were the
original pid via the sendmsg call. I am now looking for examples on
how to write up a simple test case. Any pointers?

Thanks,
BEA
 
Reply With Quote
 
 
 
 
Daneel Yaitskov
Guest
Posts: n/a

 
      07-08-2008, 06:28 PM
Beagle wrote:
> Folks,
>
> Socket(2) returns a file descriptor, used to send, write or read data
> from the socket. A process calling socket can successfully create the
> socket. I found there is a way to send the socket file descriptor to
> another process and be able to read and write data as if it were the
> original pid via the sendmsg call. I am now looking for examples on
> how to write up a simple test case. Any pointers?
>
> Thanks,
> BEA



I guess that it is impossible because someone file descriptor of a
process is is invalid in other process. The kernel uses two tables of
resources. The first table connects descriptors of process with
descriptors of kernel table. The second table is general for the kernel.

Daneel
 
Reply With Quote
 
Beagle
Guest
Posts: n/a

 
      07-09-2008, 09:56 PM
Discovered a truly amazing book (again) which goes into depth
explaining and provides source code delivering exactly the result I
was after (WOW).

Advanced Programming in the UNIX Environment, Second Edition, Chapter
17, Advanced IPC, Section 17.6. An Open Server, Version 2

http://www.apuebook.com

Others had referenced the Linux kernel, net/core/scm.c


On Jul 8, 11:28 am, Daneel Yaitskov <rtfm.rtfm.r...@gmail.com> wrote:
> Beagle wrote:
> > Folks,

>
> > Socket(2) returns a file descriptor, used to send, write or read data
> > from the socket. A process calling socket can successfully create the
> > socket. I found there is a way to send the socket file descriptor to
> > another process and be able to read and write data as if it were the
> > original pid via the sendmsg call. I am now looking for examples on
> > how to write up a simple test case. Any pointers?

>
> > Thanks,
> > BEA

>
> I guess that it is impossible because someone file descriptor of a
> process is is invalid in other process. The kernel uses two tables of
> resources. The first table connects descriptors of process with
> descriptors of kernel table. The second table is general for the kernel.
>
> Daneel


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
atomicity / thread-safety: PF_PACKET socket and tap file descriptor Max Schmied Linux Networking 0 02-28-2007 10:31 AM
Sending datagram in raw socket Vicky Linux Networking 0 10-25-2004 10:25 AM
Sending a struct over a UDP socket... Adam Balgach Linux Networking 1 09-17-2004 07:36 PM
Sending HTML page with a socket Farid Benzakour Linux Networking 1 12-11-2003 04:07 PM
Sending and reading big data by socket cyril Linux Networking 1 08-28-2003 03:58 PM



1 2 3 4 5 6 7 8 9 10 11