基于linux环境tcp网络编程(在线英英词典)文档【2】

本文档介绍如何在Linux环境下进行TCP网络编程,以实现一个在线英英词典功能。示例提供了client.c的源代码,适合想学习网络编程的读者。
摘要由CSDN通过智能技术生成

真心想学习的伙伴,需要库的朋友们请留言!

完整代码如下:

client.c

/*************************************************************************
       File Name: client.c
     Author: Young
     motto: Continuous efforts will lead to a better future 
     Created Time: Sun 2 Sep 2018 10:00:05 CST
 ************************************************************************/

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <strings.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>


#define N 64
#define M 512

typedef struct		//消息结构体
{
	int type;
	char name[N];
	char data[M];
}MSG;

int n;
void help_l();				//帮助手册
void display_1();			//第一个界面显示
void display_2();			//查询界面显示
void display_3(int sockfd, MSG *msg);	//查询界面函数
int login(int sockfd, MSG *msg);	//登录函数
int register_z(int sockfd, MSG *msg);	//注册函数
int search_word(int sockfd, MSG *msg);	//单词查询函数
int history(int sockfd, MSG *msg);	//历史记录查询函数
int return_l(int sockfd, MSG *msg);	//返回上一级,给服务器发送相应的信号


int main(int argc, char *argv[])
{
	int sockfd;	//创建套接字
	MSG msg;
	/*1.创建套接字*/
	sockfd=socket(AF_INET, SOCK_STREAM, 0);
	if(sockfd < 0)
	{
		perror("s
  • 7
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值