📄 csocket.cpp
字号:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <fcntl.h>
#include "socket.h"
#include "socket.cpp"
/////////////////////////////////////////////////////////////////////////////////////
#define REV_NUM 32
#define SND_NUM 32
//////////////////////////////////////////////////////////////////////////////////////
int main()
{
char *rev=new char[REV_NUM];//接收缓冲区
char *send=new char[SND_NUM];//发送缓冲区
send="dddddsssss";
char ip[32];
int pt;
printf("%s:\n","Input IP connected:");
scanf("%s",ip);
printf("%s:\n","Input port:");
scanf("%d",&pt);
Client_InitSocketsStruct(ip,pt);
if(Client_CreateConnection()==1)//与远程主机连接成功
{ //与远程主机的通信协议
CSendPacket(send,SND_NUM);
CRecvPacket(rev,REV_NUM);
printf("receve %s from %s \n",rev,ip);
sleep(5);
}
close(CC_sockfd);
delete []rev;
delete []send;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -