Home > OS >  Ask for help. To create a server socket, use the bind binding port problem
Ask for help. To create a server socket, use the bind binding port problem

Time:11-13

 memset (& amp; Tcpstruct, 0, sizeof (Tcpstruct)); 
Tcpstruct. Sin_family=AF_INET;
Tcpstruct. Sin_addr. S_addr=inet_addr (IP);
Tcpstruct. Sin_port=htons (port);

Bind (ServerFd, (sockaddr *) & amp; Tcpstruct, sizeof (Tcpstruct));


Just started to learn, I port in the server code passed in 66, through the converted Tcpstruct. Sin_port is 16896, and then after the program is running, with netstat found not the two view port, the four basic it is 3 w w more port number, and each run is different, through a Telnet can use netstat view port connection, this is what reason, consult the bosses

CodePudding user response:

In Ubuntu, still is this kind of situation, on the centos7 Ubuntu is WSL subsystem, g + + 7.5.0 version, centos is in vmware, g + + is 4.8.5 like
  • Related