#include #include #include #include #include #include //#define MYPORT 3900 /*this port must not exist in /etc/services */ #define MYPORT 5432 /*this port must not exist in /etc/services */ main(int argc, char * argv[]) { int sd; char buf[256]; struct servent *sp; struct hostent *hp; struct sockaddr_in sin; sd = socket(AF_INET,SOCK_DGRAM,0); /* set up UDP socket */ hp = gethostbyname(argv[1]); //hp = gethostbyname("coers6000.sdstate.edu"); bzero((char *)&sin,sizeof(sin)); bcopy(hp->h_addr,(char *)&sin.sin_addr,hp->h_length); sin.sin_port =htons(MYPORT); sin.sin_family = hp->h_addrtype; /* if (bind(sd, (struct sockaddr *) &sin, sizeof(sin)) == -1) { perror("server:bind"); close(sd); exit(1); } */ /* notice there is no connect call */ sendto(sd,"Hello",5,0,(struct sockaddr *)&sin,sizeof(sin)); }