#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <string.h>
#include <pthread.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/wait.h>
#define ERRLOG(msg) do{\
printf("%s %s %d:", __FILE__, __func__, __LINE__);\
perror(msg);\
exit(-1);\
}while(0)
#define N 128
void func(int x)
{
wait(NULL);
}
int main(int argc, const char* argv[])
{
if (3 != argc) {
printf("Usage: %s <ip> <port>\n", argv[0]);
return -1;
}
int socketfd;
if (-1 == (socketfd = socket(AF_INET, SOCK_STREAM, 0))) {
ERRLOG("socketfd error");
}
struct sockaddr_in serveraddr;
memset(&serveraddr, 0, sizeof(serveraddr));
serveraddr.sin_family = AF_INET;
serve