Question

I am new to android and I want to create a WiFi based chat engine using socket programming. I was able to retrieve the list of devices connected to WiFi using this project, now I want to create a server socket on my app to listen for connections on some port (say 6066).

My concern is that all the devices on WiFi network deployed with my app will start their service listening on the same port (say there are 192.168.1.100:6066 and 192.168.1.101:606). When I want to connect to the device with the port 6066, will it accept it?

An alternative I've considered is to specify the port as 0 in serversocket. It will assign a temporary port, but how would the client side know which one was assigned to request a connection?

Was it helpful?

Solution

yes u can set the same port number for all the clients. but u can‘t assign 0 as port number, always assign port number above 1024. and here nothing is automatically assigned. everything is assigned by the user.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top