/* NAME: tcpServer0 SYNOPSIS: tcpServer0 DESCRIPTION: The program creates a tcp socket in the inet domain, binds it to port 12345, listen and accept a connection from tcpClient0, and receives any message arrived to the socket and prints it out */ #include "def" main( argc, argv ) int argc; char *argv[]; { int sd, psd; struct sockaddr_in name; char buf[1024]; int cc; int pn; sd = socket (AF_INET,SOCK_STREAM,0); name.sin_family = AF_INET; name.sin_addr.s_addr = htonl(INADDR_ANY); pn = htons(atoi(argv[1])); name.sin_port = pn; if ( bind( sd, (SA *) &name, sizeof(name)) < 0 ) { printf("can't use port %s\n", argv[1]); exit(0); } else pause(); }