????????????
#include <stdio.h>
#include <strings.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
//#include <linux/in.h>
#include <stdlib.h>
#include <memory.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <signal.h> //?????????  ??????????????????
/**
????????????????Linux?????????Щ?????????????????????????????
???????????1??????????????????????????????2???????????????
?????????????????????????????????????????????????
*/
#define PORT    11910
#define Buflen  1024
void process_conn_client(int s);
void sig_pipe(int signo);    //??????????????????????????
int s;  //?????? ?? ?洢???????????
int main(int argc??char *argv[])
{
sockaddr_in server_addr;
int err;
sighandler_t ret;
char server_ip[50] = "";
int port = 0;
strcpy(server_ip?? argv[1]);
port = atoi(argv[2]);
/********************socket()*********************/
s= socket(AF_INET??SOCK_STREAM??0);
if(s<0)
{
printf("client : create socket error ");
return 1;
}
printf("client : socket fd = %d "?? s);
//?????????  SIGINT ??????????? Ctrl-C ???????????
ret = signal(SIGTSTP??sig_pipe);
if(SIG_ERR == ret)
{
printf("???????? ");
return -1;
}
else
printf("??????? ") ;
/*******************connect()*********************/
//???÷??????????????????????????
memset(&server_addr??0??sizeof(server_addr));
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(PORT);
server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
/*?????????????????????IP???????????????*/
//inet_pton(AF_INET??argv[1]??&server_addr.sin_addr.s_addr);
printf("please input server ip address : ");
read(0??server_ip??50);
//err = inet_pton(AF_INET??server_ip??&server_addr.sin_addr.s_addr);
server_addr.sin_addr.s_addr = inet_addr(server_ip);
err = connect(s??(struct sockaddr *)&server_addr??sizeof(sockaddr));
if(err == 0)
{
printf("client : connect to server ");
}
else
{
printf("client : connect error ");
return -1;
}
//???????????????
process_conn_client(s);
close(s);
}
void process_conn_client(int s)
{
ssize_t size = 0;
char buffer[Buflen];
for(;;)
{
memset(buffer??'