Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (428)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Telling the diffrence between two clients connected, from the same ip  (Read 2205 times)
0 Members and 1 Guest are viewing this topic.
Offline Embedded

Junior Member


Medals: 1



« Posted 2011-12-19 18:55:25 »

I cant find away to do this, for example make it so when someone connects i want to make sure they dont open two connections to the same client so i made it so if two clients have two ip then dont accept the new client, but this means you have to be in diffrent houses to play the game. If say 20 people in an office or school all connected to the game under the same IP address how can i tell the clients apart?
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 612
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2011-12-19 18:59:08 »

You can't. You can try, by grabbing something like the MAC address clientside, but that's clientside security, which means it's easily circumvented.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Embedded

Junior Member


Medals: 1



« Reply #2 - Posted 2011-12-19 19:04:13 »

Any ideas what i can do diffrently then? To stop the server recving wrong data from clients, like if im running the client which is applet based and then open a new tab and open it up in that aswell and run it really messes the game up as im guessing servers reading data from client in new tab for client in first tab
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Gudradain
« Reply #3 - Posted 2011-12-19 19:08:25 »

Make each client select a unique name when they connect and append that name to every message. With that you can determine which client send the message and the client can decide if yes or not it should process the message it just received. You might have to send the message to more than one client (every socket with the same ip?).

A simple solution would be to assign a unique ID to a client when the socket connection is established with the server. That logic should be on the server side.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 612
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2011-12-19 19:09:20 »

If you're a sane person, you're using TCP and you can simply ignore the IP all together. You're dealing with InputStreams and OutputStreams, your application shouldn't even look at the Socket after the initial code that grabs the streams from it. Abstract the network I/O away in your logic, until you're solely dealing with 'Player' objects to identify which client sent/received data and how it should handle it, preferably using something like RMI.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #5 - Posted 2011-12-19 19:12:35 »

don't hold me to this because I may be telling you something completely false. but I would imagine that if you are binding the port, the second instance of the game would crash.
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 612
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #6 - Posted 2011-12-19 19:14:13 »

client side security Cranky

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Embedded

Junior Member


Medals: 1



« Reply #7 - Posted 2011-12-19 19:19:41 »

I dont really understand what you mean, probably because i have no idea what RMI is, i kinda see what you mean. At the moment my server does just get a connection then starts a new thread with the socket passed in as argument gets the streams and it does I/O from that with logic in another thread and the I/O threads and logic threads just change static data in my other class which also displays some info.

It doesnt crash, it binds a diffrent port auto i think

you can try the game here
http://81.96.53.133/egg/WeaponHat.htm
Its fine aslong as you dont refresh the page or open two copys of it..
I like the idea of giving each client a random name and attaching it onto every packet, but okay the wrong listener on teh server gets data from a client its not supposed to be listening to, should i ignor it completely or try and pass it to the other thread or something :S
Offline Gudradain
« Reply #8 - Posted 2011-12-19 19:25:24 »

I can't answer that question without knowing about your server architecture. But usually a client will send the message only once, so on the server side you must route it to the right listener because there won't be another similar message coming from the client.
Offline Gudradain
« Reply #9 - Posted 2011-12-19 19:28:49 »

don't hold me to this because I may be telling you something completely false. but I would imagine that if you are binding the port, the second instance of the game would crash.

There is a difference between opening a port which is what a server does to listen for incoming connection and to connect to a port which is what a client does when it connect to a server. You can only open a port once, but you can connect to it many times. The port open by the server is just there to listen for new connection, when it detect one it create a new socket (on a completely different port if I'm right??) and it's with that new socket that the server just created that you are now communicating.

But that just client-server theory...

EDIT : I should recheck the part about a different port... When you ask the client socket to which port it is connected I think it says the port you specified on the server.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 612
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #10 - Posted 2011-12-19 19:32:47 »

Read the javadoc if you're not too sure what you're talking about.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline h3ckboy

JGO Coder


Medals: 5



« Reply #11 - Posted 2011-12-19 19:36:45 »

yeah, that makes sense. wasnt 100% sure, was just a thought Smiley.
Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #12 - Posted 2011-12-19 20:04:01 »

Yes you can tell them apart by grabbing the remote port. The remote port is the outgoing port randomly opened by the client to connect to your server. This port should be different for every single computer that share a router.

Offline Riven
« League of Dukes »

JGO Overlord


Medals: 612
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #13 - Posted 2011-12-19 20:11:03 »

You really shouldn't use that as a way to identify a client. Create an object on the server and let of handle the streams. Then use that object to identify the client.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Gudradain
« Reply #14 - Posted 2011-12-19 20:12:52 »

You really shouldn't use that as a way to identify a client. Create an object on the server and let of handle the streams. Then use that object to identify the client.

I don't remember why but I recall trying to use the remote port and found out it was a bad idea, so I support Riven on that one.
Offline ra4king

JGO Kernel


Medals: 322
Projects: 2
Exp: 4 years


I'm the King!


« Reply #15 - Posted 2011-12-19 20:13:32 »

Yes, of course your way is the way to go, since all Sockets are unique.

However, I'm just answering the OP's question Smiley

You really shouldn't use that as a way to identify a client. Create an object on the server and let of handle the streams. Then use that object to identify the client.

I don't remember why but I recall trying to use the remote port and found out it was a bad idea, so I support Riven on that one.
What happened?

Offline Gudradain
« Reply #16 - Posted 2011-12-19 20:15:23 »

Can't remember  Sad Sorry...

EDIT : Don't think it was critical but just that it was not practical
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (79 views)
2014-04-15 18:08:23

BurntPizza (70 views)
2014-04-15 03:46:01

UprightPath (82 views)
2014-04-14 17:39:50

UprightPath (66 views)
2014-04-14 17:35:47

Porlus (82 views)
2014-04-14 15:48:38

tom_mai78101 (106 views)
2014-04-10 04:04:31

BurntPizza (166 views)
2014-04-08 23:06:04

tom_mai78101 (262 views)
2014-04-05 13:34:39

trollwarrior1 (212 views)
2014-04-04 12:06:45

CJLetsGame (221 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!