mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-17 10:30:20 +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.
55 lines
1.2 KiB
C
55 lines
1.2 KiB
C
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <stdlib.h>
|
|
#include <sys/socket.h>
|
|
#include <sys/un.h>
|
|
|
|
#define SERVER "/tmp/serversocket"
|
|
#define CLIENT "/tmp/mysocket"
|
|
#define MAXMSG 512
|
|
#define MESSAGE "Yow!!! Are we having fun yet?!?"
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
extern int make_named_socket (const char *name);
|
|
int sock;
|
|
char message[MAXMSG];
|
|
struct sockaddr_un name;
|
|
size_t size;
|
|
int nbytes;
|
|
|
|
/* Make the socket. */
|
|
sock = make_named_socket (CLIENT);
|
|
|
|
/* Initialize the server socket address. */
|
|
name.sun_family = AF_LOCAL;
|
|
strcpy (name.sun_path, SERVER);
|
|
size = strlen (name.sun_path) + sizeof (name.sun_family);
|
|
|
|
/* Send the datagram. */
|
|
nbytes = sendto (sock, MESSAGE, strlen (MESSAGE) + 1, 0,
|
|
(struct sockaddr *) & name, size);
|
|
if (nbytes < 0)
|
|
{
|
|
perror ("sendto (client)");
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
|
|
/* Wait for a reply. */
|
|
nbytes = recvfrom (sock, message, MAXMSG, 0, NULL, 0);
|
|
if (nbytes < 0)
|
|
{
|
|
perror ("recfrom (client)");
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
|
|
/* Print a diagnostic message. */
|
|
fprintf (stderr, "Client: got message: %s\n", message);
|
|
|
|
/* Clean up. */
|
|
remove (CLIENT);
|
|
close (sock);
|
|
}
|