简体   繁体   中英

Client Side Port Detection

I have written a two separate executable file of Server and client in C. Both executable given IP/port via command line .To establish connection I give same port number to both side .

Now I want to Multi thread my Code .Right now I am specifying port number on which server should listen. But after multi thread,Suppose 5 thread want connection on five different port number. How can I multi thread client so that it automatically detect the port number of required connection.or can any other dynamic technique ??

To establish connection I give same port number to both side .

Why? It isn't necessary, and using a fixed client-side port can only be counterproductive.

Right now I am specifying port number on which server should listen. But after multi thread,Suppose 5 thread want connection on five different port number.

No problem.

How can I multi thread client so that it automatically detect the port number of required connection.

There is no problem here to solve. Don't specify the client-side port number: the system will give you a free one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM