Problems caused by duplicate listen ports

I ran into a strange problem today. A colleague from another project team had a problem when entering the cross-server. After debugging and investigation, it was found that he did not enter the cross-server. Although the role was successfully created in the cross-server application, the client did not seem to request to enter after that.

Since the colleague said that the code has not changed, the reason may be a configuration error, or a client-side problem. Asked about it, the client code has not changed. Then there is probably a configuration problem. But I did a rough investigation and found nothing unusual. It was a little frustrating at this point. But I still cheered up and scanned the cross-server and original server configurations again, and suddenly found that the port opened by the loginserver for the user turned out to be the same. This is very strange, which means that the client may want to connect to the loginserver of the cross-server, but it is connected to the original server, so naturally it will not be able to enter the cross-server.

After I changed the port, it turned out to be normal.

However, why the same port can still be activated? To me, this is a strange phenomenon. I also ran two copies of loginserver on my computer and found that the same port can be started. So I reviewed the socket study notes again and tested the bind function.

The result is that the same port cannot be opened at the same time, perror prompts: Address already in use

See this test code: https://github.com/demon90s/Beginning_Linux_Programming_CodeNote/blob/master/ch15_Sockets/example4/server.c

This can only take time to see how the internal implementation of the network module in the project is.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325011500&siteId=291194637