Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
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  
  Winsock with applets  (Read 1991 times)
0 Members and 1 Guest are viewing this topic.
Offline roland
« Posted 2009-10-06 08:43:07 »

Hi, I have winsock working on my own machine eg hosting and joining to localhost or 127.0.0.1
But I would like to make an applet where you can choose either to host or join a game and put it on my website.
Does it Have to be signed??? I don't want it to be.

http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html

Quote
Applets, therefore, are considered by default to be untrusted. Among other restrictions, an applet cannot, by default, open a socket referred to by a URL who's domain different from the domain of the page that contains the applet. This is part of the security architecture that browsers employ to protect users' computing resources from malicious or faulty applets.

this is the thing. I will only be using sockets on my site for a game, so the only socket will connect to my siteon the page which contains the applet. I will not be trying to connect to any other domain. Does this mean I can somehow get socket network programming working without signing the applets?

Offline Markus_Persson

JGO Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #1 - Posted 2009-10-06 10:19:52 »

The applet does not have to be signed to connect back to the server it was loaded from.

I've had unsigned applets connect back on port 80, so I know that works at least. I have a vague memory of hearing something about other ports not working.

Play Minecraft!
Offline roland
« Reply #2 - Posted 2009-10-06 10:31:36 »

So If I have 2 people who open the same page and load the same applet, one hosts on port 80 and the other joins to getCodeBase().getHost(), on port 80 it will work?

eg Server:
serverSocket = new ServerSocket(80, 10);
clientSocket = serverSocket.accept();
.....

and Client:
clientSocket = new Socket(getCodeBase().getHost(),80);
....

will this work? can you give me some example code?
does anyone know which ports you can use and which ones you can't?
thanks
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Mike

JGO Wizard


Medals: 86
Projects: 1
Exp: 6 years


Java guru wanabee


« Reply #3 - Posted 2009-10-06 11:20:42 »

Well, the one hosting on port 80 won't be sitting on the server I guess so in that case you'd need to sign it.

My current game, Minecraft meets Farmville and goes online Smiley
State of Fortune | Discussion thread @ JGO
Offline DzzD
« Reply #4 - Posted 2009-10-06 20:37:10 »

1  
this is the thing. I will only be using sockets on my site for a game, so the only socket will connect to my siteon the page which contains the applet. I will not be trying to connect to any other domain. Does this mean I can somehow get socket network programming working without signing the applets?


yes, you can connect back to the server that deliver the applet without signing

Socket Sample : (connect to the http server that deliver the applet)

1  
Socket s=new Socket(getCodeBase().getHost(),getCodeBase().getPort());


URL sample : (read html embedding the applet using http)

1  
URL u = new URL(getDocumentBase());

Offline roland
« Reply #5 - Posted 2009-10-07 01:48:46 »

Sorry I'm getting confused because of the mixed comments

I tried port 80 and it didnt even let me host on that port.

Quote
Well, the one hosting on port 80 won't be sitting on the server I guess so in that case you'd need to sign it.

if the person who opens the applet and hosts on port 80, is there any way to use the ip of the website as theirs instead of their own so i dont have to sign it?

Quote
yes, you can connect back to the server that deliver the applet without signing

Socket Sample : (connect to the http server that deliver the applet)

Code:

Socket s=new Socket(getCodeBase().getHost(),getCodeBase().getPort());


URL sample : (read html embedding the applet using http)

Code:

URL u = new URL(getDocumentBase());

Do you mean the server of my site which hosts my webpage?
or a person who opens my applet and hosts from that
Offline DzzD
« Reply #6 - Posted 2009-10-07 09:19:49 »

Quote
Do you mean the server of my site which hosts my webpage?

this one

Offline Markus_Persson

JGO Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #7 - Posted 2009-10-07 09:20:08 »

An unsigned applet can't open serversockets, it can only connect to others.

Play Minecraft!
Offline roland
« Reply #8 - Posted 2009-10-08 11:35:13 »

So as long as I have a signed server applet, I dont have to sign the client applets?
Offline Markus_Persson

JGO Wizard


Medals: 16
Projects: 19


Mojang Specifications


« Reply #9 - Posted 2009-10-08 11:59:48 »

They can only connect back to the server hosting the applet, not to anyone else playing on the same site
  • .
[* well, unless they're playing locally from the web server]

Play Minecraft!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #10 - Posted 2009-10-08 13:05:45 »

Roland,
If you have your socket server hosted in the same place you hosted your applet, the clients don't need to be signed .

If you have the server socket anywhere else different than the place you applet is hosted, the clients need to be signed .

If you want a player to be a server (e.g. host a game) both the host and the client party must be signed (the server side need to be signed to open a server socket, the client side need to sign because it will connect to somewhere different than the place you applet is hosted)

If you can achieve to do it like the first situation, but still want people to be able to create their "game rooms" , a workaround would be the gamerooms to be actually created in your server, not in the players machine . That will, by the way, prevent people from modifying their local server and cheat - because the logic would be running in your secure distant server . Just like a Starcraft game in Battle.net and stuff .

Offline roland
« Reply #11 - Posted 2009-10-09 00:51:35 »

thanks for the info, teletubo
I guess I will have to sign them then as I cannot host a server on my website  Cry
So if 2 people each load the same applet, one hosts and one joins, how can I stop them cheating?
Offline jezek2
« Reply #12 - Posted 2009-10-09 07:59:46 »

I guess I will have to sign them then as I cannot host a server on my website  Cry

Hosting on a website (or more precisely on some server/VPS) is better as it works nicely for people who are behind NAT. Games that requires hosting on your own computer often means that the players can't simply connect to each other, or they have to configure manually their router to do port mapping. There are some libraries (can't find them right now) that can "punch" the NATs to allow connection between two NATed clients (or non-NATed to NATed), but they're not 100% reliable either.

So if 2 people each load the same applet, one hosts and one joins, how can I stop them cheating?

You can't. And even with authoritative central server there are still many ways to cheat (eg. wallhacks, aimbots, etc.). In case you find someone cheating you can ban him by his IP though.
Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #13 - Posted 2009-10-09 12:23:57 »

You can't. And even with authoritative central server there are still many ways to cheat (eg. wallhacks, aimbots, etc.). In case you find someone cheating you can ban him by his IP though.

There is also an extensive discussion about this on this thread . You might find some interesting ideas for you . 

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.

Longarmx (49 views)
2014-10-17 03:59:02

Norakomi (38 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (35 views)
2014-10-15 16:18:58

TehJavaDev (65 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (55 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (43 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!