• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How do I make my networking code connect two pcs via Lan?  RSS feed

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have written a client server system for a turn based game. I used local host to test it using two javafx windows. Now I need to make it work with two different pcs? How can I do that and what are the requirements? Do I need to connect both with an ether net cable or do they just need to be on same WiFi?
 
Marshal
Posts: 62819
203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The actual requirements will depend on your game's requirements; if it is turn‑based like chess, the networking mightn't have a heavy workload. I suggest you try this part of the Java™ Tutorials. You can probably connect any two computers not more than 8,000 miles apart in a straight line.

Moving you to our Sockets forum.
 
Hamif Ronik
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:The actual requirements will depend on your game's requirements; if it is turn‑based like chess, the networking mightn't have a heavy workload. I suggest you try this part of the Java™ Tutorials. You can probably connect any two computers not more than 8,000 miles apart in a straight line.

Moving you to our Sockets forum.



Thanks for the link but I have looked at it before. I've already written most of the networking code but I just need a way to connect two different pcs. Then there is also the problem of figuring out which pc has the server thread the other pc needs to connect to. I also need to detect whether or not there is a server running on a pc already so that I don't launch it twice. If you could help me with that I would be very grateful.
 
Sheriff
Posts: 24080
54
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hamif Ronik wrote:Thanks for the link but I have looked at it before. I've already written most of the networking code but I just need a way to connect two different pcs. Then there is also the problem of figuring out which pc has the server thread the other pc needs to connect to. I also need to detect whether or not there is a server running on a pc already so that I don't launch it twice. If you could help me with that I would be very grateful.



Those things are not usually problems. In the vast majority of client-server setups, you run a server on computer X at port Y, and then you configure all of your clients to connect to that location. When you do it that way, both of the problems that you described don't exist. Are you doing something different than that? If so, why?
 
This is my favorite tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!