实现client向server发送数据。
server里面的rev要用nsockfd
client里面的send用sockfd
tcp_server代码:
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
#define PORT 8088 // The port which is communicate with server
#define BACKLOG 10
#define LENGTH 512 // Buffer length
int main ()
{
int iR;
int sockfd; // Socket file descriptor
int nsockfd; // New Socket file descriptor
int num;
int sin_size; // to store struct size
char sdbuf[LENGTH]; // Send buffer
char revbuf[LENGTH]; // Receive buffer
struct sockaddr_in addr_local;
struct sockaddr_in addr_remote;
// char sendstr[16]= {"123456789 abcde"};
/* Get the Socket file descriptor */
if( (sockfd = so