+ 2
[SOLVED] Cross-device Java socket connection
Hi, I had a question about Java sockets. I have only seen the client and the server both running on the same device. Is it possible for them to be on different devices and still do the communication? Like the server is in a separate device and the client is on another device with no wire-link in between. I am referring here java.net.ServerSocket and java.net.Socket.
4 Answers
+ 2
Just from doing some googling, it looks like you can, you just need to make sure you're connecting to the same port. Like have both devices connect to port 5000.
Try these answers from SO:
https://stackoverflow.com/questions/10131377/socket-programming-multiple-client-to-one-server
https://stackoverflow.com/questions/15694630/multiple-serversockets-multiple-devices-and-sending-to-multiple-sockets
+ 1
User42 thank you for the advice.
Tutorials I had followed:
1) https://youtu.be/gLfuZrrfKes
2)
https://gyawaliamit.medium.com/multi-client-chat-server-using-sockets-and-threads-in-java-2d0b64cad4a7
This is my Server-Client Program. It is a multi-client server.
https://code.sololearn.com/cwR6hIm65OrL/?ref=app
https://code.sololearn.com/c1CTU79hqs2s/?ref=app
+ 1
User42 I am glad it helped đ
0
Justice thank you very much