Socket Programming Example: TCP Shell is very simple and easy to discover, and as a Socket programming example learning.
/ * ================================================================================================================================================================ ===================================================================================================== Unyun (unywn4th@usa.net) ========================================== ============================================ * / #include
1; int acclen = sizeof (acc); memset ((char *) & address, 0, sizeof (address)); address.sin_family = AF_INET; address.sin_port = htons (port); address.sin_addr.s_addr = htonl (INADDR_ANY ); listening_socket = socket (AF_INET, socket_type, 0); if (listening_socket <0) {perror ( "socket"); exit (1);}! if (listener = NULL) * listener = listening_socket; setsockopt (listening_socket, SOL_SOCKET , SO_REUSEADDR, (void *) & reuse_addr, sizeof (reuse_addr)); if (bind (listening_socket, (struct sockaddr *) & address, sizeof (address)) <0) {perror ( "bind"); close (listening_socket); exit (1);}} (socket_type == Sock_Stream) {if (listen (listen) == - 1) {Perror ("listen"); exit (1);}}} void sock_puts (sockfd, str) int INT Sockfd; char * STR; {char x [2000], * BUF; SIZE_T BYTES_SENT = 0; int this_write, count; sprintf (x, "/ r% s", str); count = strlen (x); buf = x; while (bytes_sent