Get the App
SLTechnology News&Howtos  ›  Development  › 

How to implement chat Program on C++

Shulou Source: shulou.com Published: 2022-05-31 22:22:01 09月21日 Update

This article introduces the relevant knowledge of "how to implement the chat program on C++". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Server side

# include#include#pragma comment (lib, "ws2_32.lib") using namespace std;void initialization (); int main () {/ / defines the length variable int send_len=0; int recv_len=0; int len=0;// defines the send buffer and accept buffer char send_buf; char recv_buf; / defines the server socket and accepts the request socket SOCKET socket server; SOCKET server address / server address client address SOCKADDR_IN accept_addr; initialization (); / / populate server information server_addr.sin_family=AF_INET; server_addr.sin_addr.S_un.S_addr=htonl (INADDR_ANY); server_addr.sin_port=htons (1234); / / create socket s_server=socket (AF_INET,SOCK_STREAM,0); if (bind (s_server, (SOCKADDR *) & server_addr,sizeof (SOCKADDR)) = = SOCKET_ERROR) {cout

Tags: Services sockets fonts versions messages addresses success clients clients buffers monitoring buffering data status programs caching content variables more servers Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Docker Huawei vpn Apple