Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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  
  About UDP  (Read 2751 times)
0 Members and 1 Guest are viewing this topic.
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Posted 2010-06-08 17:42:11 »

Hai!

I have tried for quite some time now, and I simply cant find a single quality tutorial/informative thread-something, talking about how UDP works within java.
Something that tells about why the amount of bytes are sent, and when they should be. Rechieving and sending.

If any of you have stumbled upon a such text, please link me!

Thanks

Online Riven
« League of Dukes »

JGO Overlord


Medals: 798
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2010-06-08 19:14:43 »

http://www.google.com/search?q=java+tutorial+udp
 => http://java.sun.com/docs/books/tutorial/networking/datagrams/index.html

It doesn't get much clearer than that Smiley

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

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #2 - Posted 2010-06-09 08:50:00 »

Now theres some questions that still stand a bit unclear.
How do I package something in a package client -> server, and how do I request a method to be ran client -> server or server/client?

The article just said how to send a string with a package, but how do I request methods to be ran? :-)

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Stranger

Senior Member


Medals: 6



« Reply #3 - Posted 2010-06-09 10:37:39 »

Try the library Kryonet ...

Anton
Offline williamwoles

Senior Newbie





« Reply #4 - Posted 2010-06-09 10:57:47 »

The article just said how to send a string with a package, but how do I request methods to be ran? :-)

When the data is received on client or server, you should parse what is coming in the string. Imagine, you send from client to server following string: "upd_pos:1:10:15". On server you got some kind of selector(at list I use to call the method which detects what request was received from client), which takes the first part of the string and analyze it. Selector detects that the first string is "upd_pos", so it knows what is the method needed to handle the data, for example method updatePosition. You pass the string, or the unparsed part of the string to the method and the method updatePosition continues parsing.
There should be defined protocol, either made by yourself or already existing one, protocol is need for server to know what each string means. Though the string I gave you is just an example, in case of communication probably I would use JSON or in worth case XML(in my own practice using XML for RT games generates much more traffic then JSON).

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #5 - Posted 2010-06-09 11:07:46 »

So how excactly do I check the code for the protocol to know what to do? .startsWith("") ?

Offline williamwoles

Senior Newbie





« Reply #6 - Posted 2010-06-09 11:15:55 »

So how excactly do I check the code for the protocol to know what to do? .startsWith("") ?

I'm not sure about if the JSON I'm positing is esthetically right, since the applications I made previously all used XML and after figuring out the problems using of XML I only planning to investigate how to pass that to JSON and how correct JSON is being created, but the string could look like:
1  
2  
3  
4  
5  
6  
{
    "request": "upd_pos",
    "character_id": 1,
    "line": 10,
    "column": 10
}

Using GSON(library of Google that allows JSON) parsing you get every element of the JSON and you can parse the type of request which arrived depending on the "request" element.

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #7 - Posted 2010-06-09 13:44:13 »

yeah, but how is that string read, by the rechiever? How do you seperate the things?

Offline williamwoles

Senior Newbie





« Reply #8 - Posted 2010-06-09 16:19:17 »

yeah, but how is that string read, by the rechiever? How do you seperate the things?

Check this out Wink
http://sites.google.com/site/gson/gson-user-guide

Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #9 - Posted 2010-06-09 16:40:47 »

I am not using Gson, or any other extensive library. How do you do it in java manually?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Riven
« League of Dukes »

JGO Overlord


Medals: 798
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #10 - Posted 2010-06-09 21:53:30 »

I am not using Gson, or any other extensive library. How do you do it in java manually?

That has nothing to do with UDP (or networking for that matter).

Please take the time to learn Java. That will get you somewhere, in the end. Even if we'd answer your questions directly, it'd be meaningless to you. It's like asking for the rules in poetry in a foreign language - learn to speak it fluently first, then start with poetry. So much for the worst analogy ever.

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

JGO Kernel


Medals: 42
Projects: 11
Exp: 10 years


Game Engineer


« Reply #11 - Posted 2010-06-09 21:57:15 »

That has nothing to do with UDP (or networking for that matter).

Please take the time to learn Java. That will get you somewhere, in the end. Even if we'd answer your questions directly, it'd be meaningless to you. It's like asking for the rules in poetry in a foreign language - learn to speak it fluently first, then start with poetry. So much for the worst analogue ever.
Analogy?

See my work:
OTC Software
Online Riven
« League of Dukes »

JGO Overlord


Medals: 798
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #12 - Posted 2010-06-09 21:58:25 »

Analogy?

Oh shut it Tongue

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
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.

BurntPizza (13 views)
2014-09-19 03:14:18

Dwinin (31 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (79 views)
2014-09-10 06:39:09

Tekkerue (40 views)
2014-09-09 02:24:56

mitcheeb (62 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (30 views)
2014-09-07 01:12:14

Longarmx (36 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!