Socket Addresses

Shaun ARundell shaun at sauron.OZ
Sun Aug 3 07:22:01 AEST 1986


In have been working on a BSD4.3 ipc program and have come across
a few things that puzzel me.

The format for a socket address in <sys/socket.h> is

struct sockaddr {
	u_short	sa_family;		/* address family */
	char	sa_data[14];		/* up to 14 bytes of direct address */
};

May times I have seen a AF_UNIX address structure like

struct sa {
	short	family;
	char	path[LARGE_NUMBER];
};

I take that this means that a socket address structure for AF_UNIX
consists of a short (decribing the family) and as much data following
that as you want.

This would make sense. We all know (I think) that the socket system
calls impose no address structure on the sockets but that different 
families expect there addresses in a certin formats.

NOW  - what can you say something like this

server - 
	s = socket(AF_UNIX,  SOCK_STREAM, 0);
	...
	bind(s, "server", sizeof( "server" ) );
	...
	listen(s, 5)
	...
	accept(s, &from, &fromlen ); 

client -

	s = socket(AF_UNIX, SOCK_STREAM, 0 );
	...
	bind(s, "client", sizeof( "another_server" ) );
	...
	connect(s, "server" , sizeof("server") );
	...

	chat away

socket ADDRESSES have me confused. Can any body clear up the 
confusion.



     \XX	Shaun  Arundell		ARPA: munnari!sauron.oz!shaun at SEISMO
      \X	Technical Support	UUCP: seismo!munnari!sauron.oz!shaun
XXXXX  \XXXX    GOULD COMPUTERS		ACS:  shaun at sauron.oz
XXXXX  /XXXX   
      /X 	Telephone	        STD:  (02) 957-2522
     /XX            			ISD: +61 2 957-2522 



More information about the Comp.unix.wizards mailing list