[SDL] SDL_net and socketpair

José Luis Sánchez wizord at mi.madritel.es
Thu Sep 5 13:32:01 PDT 2002


Neil Griffiths <n.griffiths at virgin.net> escribió:

> Hiya,
> 
> JLS> Sorry but your point is not valid.  socketpair is generally supported by
> JLS> a special system call that does all the job.  As the sockets aren't
> JLS> really of TCP domain, there is no need for listen, connect etc. and the
> JLS> kernel doesn't do it either.
> 
> Then it's not just socketpair() that's wanted, but that wasn't the
> question. And my point was perfectly valid. You still need to use
> socket() to create a socket, socketpair() creates a pair of sockets
> for you. You need to pass across the type of data (TCP, Datagram etc)
> for both functions. So my point is valid and you generally don't have
> one at all. ;) I was using connect(), listen etc as examples of there
> being no difference between calling socket() twice and using
> socketpair().

Nonsense.  socketpair creates a pair of sockets and connects them, and it
usually does it bypassing much of the overhead involved on normal sockets work.

OTOH, sockets created by socketpair don't use TCP, datagrams and all that. 
They are a different family of sockets (AF_UNIX) and only work on a single
machine (i.e. they don't work across a network).

You can take a look at sys_socket and sys_socketpair syscalls on Linux kernel
and see the difference.  socketpair is a very simple function whereas socket is
really complex.

> http://www.mkssoftware.com/docs/man3/socketpair.3.asp
> http://unixhelp.ed.ac.uk/CGI/man-cgi?socketpair+2

Hey, if you read carefully those man pages, you'll see what I mean.

Regards,
Wizord.




More information about the SDL mailing list