LinuxC之socket通信实现简单的计算器
代码如下:
服务器端代码:
#include<stdio.h>
#include<unistd.h>
#include<string.h>
#include<stdlib.h>
#include<netinet/in.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<string.h>
#include<arpa/inet.h>
#define SERVER_PORT 5576
#define LISTEN_QUEUE 1000
#define BSIZE 1024
typedef struct
{
char s[100];
float a;
float b;
}Node,*PNode;
int main(int argc,char *argv[])
{
struct sockaddr_in server_addr;
bzero(&server_addr,sizeof(server_addr));
server_addr.sin_family=AF_INET;
server_addr.sin_addr.s_addr=inet_addr("127.0.0.1");
server_addr.sin_port=htons(SERVER_PORT);
int server_socket=socket(AF_INET,SOCK_STREAM,0);
if(