DATAGRAM sockets in the UNIX DOMAIN.

DATAGRAM sockets in the UNIX DOMAIN.

Post by Vipin P » Sun, 02 Sep 1990 14:58:00



Help needed with INTERRUPTS when used with DATAGRAM sockets
in the UNIX domain.

At the moment we have a simple CLIENT/SERVER model where
the communication is done using DATAGRAM sockets in the INET domain
with INTERRUPTS which works successfully.

The same exercise in the UNIX  domain has not been sucessful.
A skeleton code is supplied to clarify (hopefully)

/*  SERVER */
struct sockaddr_un sock;
fd=socket(AF_UNIX,SOCK_DGRAM,0);  /*create a socket */
bind(fd,&sock,sizeof(sock.sun_family)+1+strlen(sokname))
                                  /*binding tjhe socket */
icotl(fd,FIOASYNC,(char*)&fioasync) /* setting flag for async I/O */
icotl(fd,SIOCSPGRP,(char*)&pid)     /* set process group pid for signal  */
signal(SIGIO,sig_handler)
sigpause(SIGIO)
.
.
/* END SERVER */

/*  CLIENT */
struct sockaddr_un sock;
fd=socket(AF_UNIX,SOCK_DGRAM,0);  /*create a socket */
bind(fd,&sock,sizeof(sock.sun_family)+1+strlen(sokname))
                                  /*binding the socket */
icotl(fd,FIOASYNC,(char*)&fioasync) /* setting flag for async I/O */
icotl(fd,SIOCSPGRP,(char*)&pid)     /* set process group pid for signal  */
signal(SIGIO,sig_handler)
.
.
sendto(fd,...)               /*sendto SERVER */
.
.
.
sigpause(SIGIO)
.
/* END CLIENT */

sig_handler() performs recvfrom for the CLIENT  and
              recvfrom & sendto for the SERVER.

We would like to hear from people who have had similar experiance
or success!!
--
Regards


 
 
 

DATAGRAM sockets in the UNIX DOMAIN.

Post by Eddie Wya » Sun, 02 Sep 1990 14:38:00


Quote:> /*  SERVER */
> struct sockaddr_un sock;
> fd=socket(AF_UNIX,SOCK_DGRAM,0);  /*create a socket */
> bind(fd,&sock,sizeof(sock.sun_family)+1+strlen(sokname))
>                              /*binding tjhe socket */
> icotl(fd,FIOASYNC,(char*)&fioasync) /* setting flag for async I/O */
> icotl(fd,SIOCSPGRP,(char*)&pid)     /* set process group pid for signal  */

                            ^^^^

    int pgrp = -getpid();

    (void) signal(_WHICH_INTERRUPT,urgent_message_processor);
    (void) ioctl(port,SIOCSPGRP, (char *) &pgrp);

Quote:> signal(SIGIO,sig_handler)
> sigpause(SIGIO)
> .
> .
> /* END SERVER */

> /*  CLIENT */
> struct sockaddr_un sock;
> fd=socket(AF_UNIX,SOCK_DGRAM,0);  /*create a socket */
> bind(fd,&sock,sizeof(sock.sun_family)+1+strlen(sokname))
>                              /*binding the socket */
> icotl(fd,FIOASYNC,(char*)&fioasync) /* setting flag for async I/O */
> icotl(fd,SIOCSPGRP,(char*)&pid)     /* set process group pid for signal  */

                             ^^^
                        Same here.

Quote:> signal(SIGIO,sig_handler)
> .
> .
> sendto(fd,...)               /*sendto SERVER */
> .
> .
> .
> sigpause(SIGIO)
> .
> /* END CLIENT */

> sig_handler() performs recvfrom for the CLIENT  and
>          recvfrom & sendto for the SERVER.

                                Eddie Wyatt
--

                                        Eddie Wyatt



 
 
 

DATAGRAM sockets in the UNIX DOMAIN.

Post by Chris Tor » Sun, 02 Sep 1990 19:12:00



>>ioctl(fd,SIOCSPGRP,(char*)&pid)     /* set process group pid for signal  */
>                        ^^^^
>    int pgrp = -getpid();
>    (void) ioctl(port,SIOCSPGRP, (char *) &pgrp);

Careful; the semantics were reversed in the change from 4.2BSD to
4.3BSD.  (I had nothing to do with this!)  See your socket(2) and
fcntl(2) manuals for details.  I think -getpid() => pgrp on 4.3BSD,
and -getpid() => pid on 4.2BSD.
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690)

 
 
 

1. UNIX domain datagram sockets

I am just starting to learn about sockets programming using the book:

        Adventures in UNIX Network Applications Programmimg - WILEY

I am looking at the UNIX domain to start with.

The connectionless datagram examples work fine on SUNs but not under Linux.
connect() returns INVALID PARAMETER as does recv(). I also noticed that
recv() does not block.

Can any one tell me if Are datagram sockets fully supported in the
UNIX domain under linux?

Thanks for any help

John

2. Slow connection

3. UNIX Domain Datagram Sockets - Receive Queue Size?

4. Upgrade problem Solaris 8

5. UNIX domain Socket Datagram question

6. DNS resolution not always working.

7. UNIX Domain Datagram Socket:Receive Queue Size?

8. Compile problems under RH5.1

9. Not enough queuing of datagrams on a unix domain socket

10. Datagram sockets in Unix Domain?

11. Are unix domain socket datagrams reliable?

12. credentials from Unix-domain datagram socket?