一.客户端类实现 流程:1.创建网络套接字 2.bind固定端口用于消息的接收 3.使网络套接字支持广播 4.创建两个标准线程用于消息的接收和发送 #include "Log.hpp" #include <cstring> #include <cstdlib> #include <iostream> #include <unistd.h> #include <strings.h> #include <pthread.h> #include <sys/types.h> #include <arpa/inet.h> #include <netinet/in.h> #include <sys/socket.h> #define CLIENTIP "192.168.0.27" #define CLIENTPORT 8080 Log lg; enum { SOCKET_ERR = 1, BIND_ERR }; namespace black { struct ThreadData { int socket_fd; struct sockaddr_in client_other; };...
Is this you? As a journalist, you can create a free Muck Rack account to customize your profile, list your contact preferences, and upload a portfolio of your best work.
Claim your profile