3 #include <sys/socket.h>
9 int port
, newsockfd
, clilen
, childpid
, sockfd
;
10 struct sockaddr_in cli_addr
, serv_addr
;
13 char * SERVER_CLOSE(char * a
, char * b
){
19 char * SERVER_ACCEPT(char * a
, char * b
){
20 clilen
= sizeof(cli_addr
);
21 newsockfd
= accept(newsockfd
, (struct sockaddr
*) &cli_addr
, &clilen
);
25 char * SERVER_WRITE(char * a
, char * b
){
26 written
= write(newsockfd
, b
, strlen(b
));
30 char * SERVER_READ(char * a
, char * b
) {
32 read(newsockfd
, ptr
, atoi(b
));
37 char * SERVER_BIND(char * a
, char * b
){
39 sockfd
= socket(AF_INET
, SOCK_STREAM
, 0);
42 bzero((char *) &serv_addr
, sizeof(serv_addr
));
43 serv_addr
.sin_family
= AF_INET
;
44 serv_addr
.sin_addr
.s_addr
= htonl(INADDR_ANY
);
45 serv_addr
.sin_port
= htons(port
);
47 bind(sockfd
, (struct sockaddr
*) &serv_addr
, sizeof(serv_addr
));