Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
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  
  Easiest networking libraries for Java  (Read 1230 times)
0 Members and 1 Guest are viewing this topic.
Offline orange451

JGO Kernel


Medals: 452
Projects: 7
Exp: 7 years


Your face? Your ass? What's the difference?


« Posted 2018-06-29 20:50:40 »

Hiah, in my next project I don't want to use my own networking boilerplate code. I'd rather use a library. I was wondering what the best libraries to do this were. All I am looking for is someway to create sockets and repeatedly read write bytes from them. It'll be used for fast paced games. I'm not looking for something that abstracts what I'm sending too much, If that makes sense.

First Recon. A java made online first person shooter!
Online VaTTeRGeR
« Reply #1 - Posted 2018-06-29 21:41:20 »

I don't know if this helps you, but here's my version of what you asked for.

https://github.com/VaTTeRGeR/orts_game/blob/master/game_src/de/vatterger/engine/network/layered/DatagramChannelQueue.java

The only external dependency is LibGDXs MathUtils.clamp(val, min, max) function, so it's basically vanilla java nio/io.

Features:
  • Datarate limiting
  • Configurable UDP buffer size (within system limits)
  • Configurable packet-drop-on-overload
  • Configurable socket read/write update frequency
  • Concurrent read/write methods
  • It should be quite robust. I tested it a lot...

Starting an datarate-limited endpoint on localhost:27000:
1  
2  
3  
InetSocketAddress bindAddress = new InetSocketAddress("localhost", 27000);
DatagramChannelQueue queue = new DatagramChannelQueue(bindAddress, 100*1024); //100kbyte/s rate limit
queue.bind();


Sending a byte array:
1  
queue.write(remoteAddress, new byte[1024]);


Checking for received messages:
1  
2  
3  
4  
DatagramPacket packet = null;
while((packet = queue.read()) != null) {
   reactToMessageInYourGame(packet.getData(), packet.getSocketAddress()));
}


Closing an endpoint:
1  
queue.unbind();


I started working on a RUDP-esque version of the above and it's basically working, but it needs a rewrite before it's usable.
Offline orange451

JGO Kernel


Medals: 452
Projects: 7
Exp: 7 years


Your face? Your ass? What's the difference?


« Reply #2 - Posted 2018-06-30 14:42:36 »

That looks fantastic!

First Recon. A java made online first person shooter!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ral0r2
« Reply #3 - Posted 2018-07-01 08:32:00 »

I'm not sure whether this might be a little overkill for you, but I could recommened kryonet

https://github.com/EsotericSoftware/kryonet
Offline ii8

Junior Devvie


Medals: 1
Exp: 3 years



« Reply #4 - Posted 2018-08-06 08:37:07 »

I know two good libs:
1. Netty - https://github.com/netty/netty
2. Okio - https://github.com/square/okio
Good luck Smiley
Offline Gornova
« Reply #5 - Posted 2018-08-06 16:12:07 »

From my experience Kryonet is really solid and good choice

Blog | Last game Drone Swarm
Offline nsigma
« Reply #6 - Posted 2018-08-06 16:50:36 »


Don't you mean OkHttp?  Noticed this being used in a library recently by someone whose opinion I respect a lot.  Not used it myself as yet though.

Praxis LIVE - hybrid visual IDE for (live) creative coding
Offline ii8

Junior Devvie


Medals: 1
Exp: 3 years



« Reply #7 - Posted 2018-08-06 18:32:48 »

OkHttp is perfect, if you just need http. It used to Okio under the hood.
Offline philfrei
« Reply #8 - Posted 2018-08-06 18:34:03 »

It would be good to consolidate this info on our resources page.

music and music apps: http://adonax.com
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (290 views)
2018-11-16 13:46:03

hadezbladez (160 views)
2018-11-16 13:41:33

hadezbladez (291 views)
2018-11-16 13:35:35

hadezbladez (72 views)
2018-11-16 13:32:03

EgonOlsen (2152 views)
2018-06-10 19:43:48

EgonOlsen (2178 views)
2018-06-10 19:43:44

EgonOlsen (1367 views)
2018-06-10 19:43:20

DesertCoockie (1984 views)
2018-05-13 18:23:11

nelsongames (1626 views)
2018-04-24 18:15:36

nelsongames (2274 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46
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!