문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top