Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/valkryst/vudp
A simple library for sending and receiving packets over UDP.
https://github.com/valkryst/vudp
client network packet packet-processor packets server socket udacity udp udp-client udp-server
Last synced: about 1 month ago
JSON representation
A simple library for sending and receiving packets over UDP.
- Host: GitHub
- URL: https://github.com/valkryst/vudp
- Owner: Valkryst
- License: mit
- Created: 2018-04-11T15:37:21.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-11T13:27:24.000Z (over 1 year ago)
- Last Synced: 2024-11-06T21:45:02.801Z (3 months ago)
- Topics: client, network, packet, packet-processor, packets, server, socket, udacity, udp, udp-client, udp-server
- Language: Java
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE.md
Awesome Lists containing this project
README
![](https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiSk5CSnJDUm10YnYwLzIyMnZhOTkxZDVkWlhjUGtuMWFOVEMvNW14ZitUSU5iMWdUdG1WSWlUN1pneDE3L0xUYWZVMFl4M0hzMzdqSEdLTWJJRVQrTFNZPSIsIml2UGFyYW1ldGVyU3BlYyI6ImJqeGlzS3h4ZFVtaHliZ2UiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master) [![Release](https://jitpack.io/v/Valkryst/VUDP.svg)](https://jitpack.io/#Valkryst/VUDP)
## Links
* [Examples](https://github.com/Valkryst/VUDP/wiki)
## Jar Files & Maven
The Maven dependency is hosted off of JitPack, so you will need to add JitPack as a repository before you add VUDP as a dependency.
### Maven
JitPack ([Example](https://github.com/Valkryst/VTerminal/blob/master/pom.xml)):
jitpack.io
https://jitpack.io
Dependency:
com.github.Valkryst
VUDP
1.2.0
### Jar
Jar files can be found on the [releases](https://github.com/Valkryst/VUDP/releases) page.
## Example
In this example, we create a `PacketReadWriter`, then we continuously send, receive, and display 100 packets on the local machine.
```java
package com.valkryst.VUDP;import lombok.Getter;
import lombok.NonNull;import java.io.IOException;
import java.io.Serializable;
import java.net.DatagramPacket;public class Driver {
public static void main(String[] args) throws IOException, InterruptedException {
final String serverHost = "127.0.0.1";
final int serverPort = 9998;
final int clientPort = 9998;
final PacketReadWriter readWriter = new PacketReadWriter(serverHost, serverPort, clientPort);
readWriter.start();for (int i = 0 ; i < 100 ; i++) {
final Message sendMessage = new Message("Packet #" + i);
readWriter.queuePacket(sendMessage.toPacket());final DatagramPacket packet = readWriter.dequeuePacket();
final Message receivedMessage = (Message) Package.fromPacket(packet);
System.out.println("Received Packet: " + receivedMessage.getMessage());Thread.sleep(100);
}readWriter.shutdown();
}private static class Message implements Package, Serializable {
/** The message. */
@Getter
private final String message;/**
* Constructs a new Message.
*
* @param message
* The message.
*/
public Message(final @NonNull String message) {
this.message = message;
}
}
}
```