mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-22 19:00:07 +00:00
356d71003e
1998-04-07 Andreas Jaeger <aj@arthur.rhein-neckar.de> * sysdeps/unix/sysv/linux/bits/sockunion.h: Fix error message. * manual/socket.texi (Interface Naming): Fix typo. 1998-04-07 Andreas Jaeger <aj@arthur.rhein-neckar.de> * manual/examples/filesrv.c (main): Remove filename first. * manual/socket.texi (Address Formats): Change ?F_LOCAL, ?F_FILE, ?F_UNIX. * manual/examples/mkfsock.c (make_named_socket): Use PF_LOCAL instead of PF_UNIX. * manual/examples/filecli.c (main): Use AF_LOCAL instead of AF_UNIX. 1998-04-09 Ulrich Drepper <drepper@cygnus.com> * sysdeps/libm-ieee754/s_signgam.c: Define __signgam and make signgam weak alias. * sysdeps/libm-ieee754/w_lgamma.c: Use __signgam not signgam. * sysdeps/libm-ieee754/w_lgammaf.c: Likewise. * sysdeps/libm-ieee754/w_lgammal.c: Likewise. * sysdeps/libm-ieee754/w_gamma.c: Likewise. * sysdeps/libm-ieee754/w_gammaf.c: Likewise. * sysdeps/libm-ieee754/w_gammal.c: Likewise. * login/utmp_daemon.c (open_socket): Use __connect not connect. * sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h (SA_LEN): New macro. * Makerules: Re-add missing rule for $(objpfx)stamp.oS.
49 lines
1.0 KiB
C
49 lines
1.0 KiB
C
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <stdlib.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/un.h>
|
|
|
|
#define SERVER "/tmp/serversocket"
|
|
#define MAXMSG 512
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
int sock;
|
|
char message[MAXMSG];
|
|
struct sockaddr_un name;
|
|
size_t size;
|
|
int nbytes;
|
|
|
|
/* Remove the filename first, it's ok if the call fails */
|
|
unlink (SERVER);
|
|
|
|
/* Make the socket, then loop endlessly. */
|
|
sock = make_named_socket (SERVER);
|
|
while (1)
|
|
{
|
|
/* Wait for a datagram. */
|
|
size = sizeof (name);
|
|
nbytes = recvfrom (sock, message, MAXMSG, 0,
|
|
(struct sockaddr *) & name, &size);
|
|
if (nbytes < 0)
|
|
{
|
|
perror ("recfrom (server)");
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
|
|
/* Give a diagnostic message. */
|
|
fprintf (stderr, "Server: got message: %s\n", message);
|
|
|
|
/* Bounce the message back to the sender. */
|
|
nbytes = sendto (sock, message, nbytes, 0,
|
|
(struct sockaddr *) & name, size);
|
|
if (nbytes < 0)
|
|
{
|
|
perror ("sendto (server)");
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
}
|
|
}
|