This week's giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Production-Ready Serverless (Operational Best Practices) and have Yan Cui on-line!
See this thread for details.
Win a copy of Production-Ready Serverless (Operational Best Practices) this week in the Cloud/Virtualization forum!
  • 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
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

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: 63777
209
  • 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: 24282
55
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?
 
That new kid is a freak. Show him this tiny ad:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!