In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-10-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article Xiaobian for everyone to introduce in detail "C++ based socket UDP network programming how to achieve chat room function", detailed content, clear steps, details properly handled, I hope this article "C++ based socket UDP network programming how to achieve chat room function" article can help you solve doubts, the following with Xiaobian's ideas slowly in-depth, together to learn new knowledge bar.
0. Flow chart of communication steps
(Left: Server; Right: Client)
1. server code
1.1 Server class header file (CServer_UDP.h)
#pragma once #include class CServer_UDP{public: CServer_UDP(); void SendMsg(const char sendBuf[]); void RecMsg(); ~CServer_UDP(); private: SOCKET m_sServer; struct sockaddr_in m_SocAddrClient; //Used to save client information bool m_terminal;} when establishing a connection;
1.2 Server class source file (CServer_UDP.cpp)
#define _WINSOCK_DEPRECATED_NO_WARNINGS#include "CServer_UDP.h" #include #pragma comment(lib, "ws2_32.lib") CServer_UDP::CServer_UDP():m_terminal(false){ //must be initialized as follows, otherwise socket() returns 10093 error//initialize WSA WORD sockVersion = MAKEWORD(2, 2); WSADATA wsaData; if (WSAStartup(sockVersion, &wsaData) != 0)//initialize ws2_32.dll { std::cout} via a process
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.