linux网络编程学习记录

1.把xmind安装上去,这样方便看思维导图软件


linux网络编程学习记录_第1张图片
image.png

客户端的程序

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

int main(void)
{
    int l_iSocketFd = 0;
    struct sockaddr_in l_stSeverAddr;
    char l_szBuff[100];
    int l_iBytes = 0;

   l_iSocketFd = socket(AF_INET, SOCK_STREAM, 0);

   bzero(&l_stSeverAddr, sizeof(l_stSeverAddr));

   l_stSeverAddr.sin_family = AF_INET;
   l_stSeverAddr.sin_addr.s_addr = inet_addr("127.0.0.1");
   l_stSeverAddr.sin_port = htons(8888);

   connect(l_iSocketFd, (struct sockaddr*)&l_stSeverAddr, sizeof(l_stSeverAddr));

   l_iBytes = read(l_iSocketFd, l_szBuff, 100);

   printf("bytes read number:%d\n", l_iBytes);
   printf("Time:%s\n", l_szBuff);
    return 0;
}

你可能感兴趣的:(linux网络编程学习记录)