#include <stdio.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <arpa/inet.h>
#include <ctype.h>

int main(int argc, char *argv[])
{ const unsigned char IPno[] = {10, 2, 73, 86};
  int   i, sd, nb, taille = 16;
  char bfr[1024], *ptr; 
  struct sockaddr_in serv, client;
  struct sockaddr    aux;
  sd = socket( AF_INET, SOCK_DGRAM, 0);
  memset( &serv, 0 , sizeof(serv) );
  serv.sin_family = AF_INET;       
  serv.sin_port = htons( 31415 );
  memcpy( &serv.sin_addr, IPno, 4); 
  bind( sd, (struct sockaddr *) &serv, sizeof(serv));
  while ( 1 ) {
      nb = recvfrom( sd, &bfr, 1024 , 0, &aux , &taille);
      memcpy( &client, &aux, sizeof(aux) );
      ptr = inet_ntoa( client.sin_addr )  ;
      printf("\n%d octets <-(%s): ", nb, ptr);
      for( i = 0; i < nb; i++) 
	if ( isprint( bfr[i] ) ) printf("%c", bfr[i] );
  }
  close(sd);
  return 0;
}
