CorpNet

Java R-UDP network library

License

License

Categories

Categories

Net
GroupId

GroupId

net.corpwar.lib
ArtifactId

ArtifactId

corpnet
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

CorpNet
Java R-UDP network library
Project URL

Project URL

http://www.corpwar.net/wp/corpnet-r-udp-framework-in-java/
Source Code Management

Source Code Management

http://github.com/CorpWar/CorpNet

Download corpnet

How to add to project

<!-- https://jarcasting.com/artifacts/net.corpwar.lib/corpnet/ -->
<dependency>
    <groupId>net.corpwar.lib</groupId>
    <artifactId>corpnet</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.corpwar.lib/corpnet/
implementation 'net.corpwar.lib:corpnet:2.0.0'
// https://jarcasting.com/artifacts/net.corpwar.lib/corpnet/
implementation ("net.corpwar.lib:corpnet:2.0.0")
'net.corpwar.lib:corpnet:jar:2.0.0'
<dependency org="net.corpwar.lib" name="corpnet" rev="2.0.0">
  <artifact name="corpnet" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.corpwar.lib', module='corpnet', version='2.0.0')
)
libraryDependencies += "net.corpwar.lib" % "corpnet" % "2.0.0"
[net.corpwar.lib/corpnet "2.0.0"]

Dependencies

test (1)

Group / Artifact Type Version
junit : junit jar 4.11

Project Modules

There are no modules declared in this project.

CorpNet

Build Status Chat on Gitter

You can find the latest snapshot version here

If you want a fast UDP network library for your multiplayer game or application that support both reliable and unreliable packages, then this is the library for you. This library work on both desktop and on Android.

Java R-UDP network library with three different types

  • Client <-> Server
  • PeerToPeer
  • PeerToPeer with establishing connection via a master server

How to get going

I have added a wiki page that describe how to get going and how to use this library, so head over to the wiki to get started. If there are something that is hard to understand just add an issue and I take a look at it.

You can ether grab it from maven central

<dependency>
    <groupId>net.corpwar.lib</groupId>
    <artifactId>corpnet</artifactId>
    <version>2.0.0</version>
</dependency>

Or you can head over to release section and download the latest version of the jar. Add this to your project and you should be good to go.

Why use UDP instead of TCP

I did this library mostly to learn more about network but also after I read this article from Glenn Fiedler. He describe very good why UDP can be more beneficial in some situation. If you should do games with multiplayer I suggest you read that article before you start.

What this R-UDP support

There have been some things added to this library that isn't normally in UDP to get it more reliability.

  • You can send reliable package and know it will be delivered to the other side.
  • You will be informed if someone get disconnected.
  • Every package have a unique id number.
  • You can get information how long packages take to send.
  • If packages are bigger then max package size (default 512) then it will be split. If an unreliable package don't arrive, the entire message will be discarded. Reliable messages will always be delivered.
  • Flow control implemented. If to much data are sent unreliable messages are dropped. And sents are slowed down if ping goes up.

There are a few things that are not handled.

  • Packages can still come in another order then you send them, if this is a problem you have to deal with it your self and can be done via sequence number that is sent with the package.

Default max package size are set to 512 bytes. After that it will be split up in smaller chunks. If split packages are arrived in the wrong order then the framework will handle it and put it together in the right order.

All data will be sent in byte[] format. This is to give the developer full freedom how things should be sent, and that optimization can be done. To help out with transforming between objects and byte[] there will be methods for that.

If you add this library to Android don't forget this

    <uses-permission android:name="android.permission.INTERNET" />

or it will not work.

Convert objects to byte[] and back again

If you want to transform objects to byte[] and back again there are a utility class that can help you out. The object you transform need to be marked with Serializable. You can check out SerializationUtilsTest.java in the repository to find out more how to use this. The code below are just a snipet how to use it. This is work in progress and can be change.

byte[] testByte = SerializationUtils.getInstance().serialize(testSerialization);
...
TestSerialization returnObj = SerializationUtils.getInstance().deserialize(testByte);

Other great network libraries

If you looking for a good TCP and UDP library I suggest KryoNet.

Versions

Version
2.0.0
1.8.0
1.7.0