problem of socket programming with local ip
-
hi take a look at my codes:
-
hi take a look at my codes:
The client has to know where the server is. Period. There's no way that a server could notify the client of its address without the server being previously aware of the client - for the server to be previously aware of the client then the client would have had to have to connected to the server already! In other words, what you have with
localEndPoint2
is unnecessary. In order for the server to notify the client where it is they would already have to be connected and that would mean your problem is already solved. Usually on the client side the server's IP Address and Port are stored in the application's configuration. Then the server starts up and starts listening on its port, and when the client starts up it reads its configuration and it knows where to connect to.:badger: