当前位置: 技术问答>linux和unix
心跳机制问题
来源: 互联网 发布时间:2016-10-03
本文导语: 服务器 #include #include #include #include #include #include #include #include #include #include #include #include int main() { int sock,sock_fd; struct sockaddr_in addr; char buf[256]; int bytesread; if((sock=socket(AF_INET,SOCK_STREAM,0))==-1) ...
服务器
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main()
{
int sock,sock_fd;
struct sockaddr_in addr;
char buf[256];
int bytesread;
if((sock=socket(AF_INET,SOCK_STREAM,0))==-1)
{
printf("socket errorn");
exit(0);
}
memset(&addr,0,sizeof(addr));
addr.sin_family=AF_INET;
addr.sin_port=htons(13000);
if(inet_pton(AF_INET,"192.168.1.103",&addr.sin_addr.s_addr)
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
int main()
{
int sock,sock_fd;
struct sockaddr_in addr;
char buf[256];
int bytesread;
if((sock=socket(AF_INET,SOCK_STREAM,0))==-1)
{
printf("socket errorn");
exit(0);
}
memset(&addr,0,sizeof(addr));
addr.sin_family=AF_INET;
addr.sin_port=htons(13000);
if(inet_pton(AF_INET,"192.168.1.103",&addr.sin_addr.s_addr)