#include
Int socketfd, consocketfd, n; char send_str [1024]; struct sockaddr_in serddr;
IF ((socketfd = socket (AF_INET, SOCK_STREAM, 0) <0) {Printf ("CREATE SOCKET ERROR!");
Bzero (& Seraddr); seraddr.sin_family = af_inet; serddr.sin_addr.s_addr = htonl (inaddr_any); serddr.sin_port = htons (13);
IF (Bind (STRUCKETFD, STRUCKADDR *) & seraDDR, SIZEOF (SERADDR)) <0) {Printf ("Bind Socket Error!");} IF (Listen (Socketfd, 1024) <0) {Printf ("Listen Socket Error! ");
For (;;) {IF ((Consocketfd = Accept (Socketfd, (Struct SockAddr *) NULL, NULL) <0) {Printf ("Listen Socket Error!");} Sprintf (send_str, "% s / n" , "IT IS Xuang Sending ..."; if (Write (consocketfd, send_str, strlen (send_str))! = Strlen (send_str)) {Printf ("Write Socket Error!");}
IF (close (consocketfd) == - 1) Printf ("Close Socket Error!");}}