?? 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 + -