All Projects → Nishant-Pathak → mocket

Nishant-Pathak / mocket

Licence: other
Reliable UDP server client for flaky networks

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to mocket

quic vs tcp
A Survey and Benchmark of QUIC
Stars: ✭ 41 (+95.24%)
Mutual labels:  tcp, chromium, quic
Reactor Netty
TCP/HTTP/UDP/QUIC client/server with Reactor over Netty
Stars: ✭ 1,743 (+8200%)
Mutual labels:  tcp, udp, quic
Magician
Magician is a small HTTP service package based on Netty that makes it very easy to start an http service, and also supports WebSocket, using annotated configuration Handler, If you want to develop an http service with netty but find it cumbersome, then Magician may help you.
Stars: ✭ 97 (+361.9%)
Mutual labels:  tcp, udp
nc
Porting Netcat in Node.js. CLI util. 💻
Stars: ✭ 17 (-19.05%)
Mutual labels:  tcp, udp
dpdk
A comprehensive rust binding for DPDK allowing high speed userspace networking across 256 cores and 32 NICs
Stars: ✭ 30 (+42.86%)
Mutual labels:  tcp, udp
dats
📈 Minimalistic zero-dependencies statsd client for Node.js
Stars: ✭ 63 (+200%)
Mutual labels:  tcp, udp
Rmessage
Reactive Programming Multi-protocol push service
Stars: ✭ 23 (+9.52%)
Mutual labels:  tcp, udp
twjitm-core
采用Netty信息加载实现长连接实时通讯系统,客户端可以值任何场景,支持实时http通讯、webSocket通讯、tcp协议通讯、和udp协议通讯、广播协议等 通过http协议,rpc协议。 采用自定义网络数据包结构, 实现自定义网络栈。
Stars: ✭ 98 (+366.67%)
Mutual labels:  tcp, udp
socket
Dazzle Async Socket
Stars: ✭ 19 (-9.52%)
Mutual labels:  tcp, udp
knockonports
A port knocking client for Android
Stars: ✭ 25 (+19.05%)
Mutual labels:  tcp, udp
asyncio-socks-server
A SOCKS proxy server implemented with the powerful python cooperative concurrency framework asyncio.
Stars: ✭ 154 (+633.33%)
Mutual labels:  tcp, udp
doq-proxy
DNS-over-QUIC to UDP Proxy
Stars: ✭ 57 (+171.43%)
Mutual labels:  udp, quic
iit-kgp-network
Information repository and Solutions on IIT KGP Internet Problems.
Stars: ✭ 28 (+33.33%)
Mutual labels:  tcp, udp
voice
Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Stars: ✭ 310 (+1376.19%)
Mutual labels:  tcp, udp
DatagramTunneler
Simple C++ cross-platform client/server app forwarding UDP datagrams through a TCP connection.
Stars: ✭ 116 (+452.38%)
Mutual labels:  tcp, udp
ctsTraffic
ctsTraffic is a highly scalable client/server networking tool giving detailed performance and reliability analytics
Stars: ✭ 125 (+495.24%)
Mutual labels:  tcp, udp
Socketify
Raw TCP and UDP Sockets API on Desktop Browsers
Stars: ✭ 67 (+219.05%)
Mutual labels:  tcp, udp
ccxx
This is a cross-platform library software library about c, c ++, unix4, posix. Include gtest, benchmark, cmake, process lock, daemon, libuv, lua, cpython, re2, json, yaml, mysql, redis, opencv, qt, lz4, oci ... https://hub.docker.com/u/oudream
Stars: ✭ 31 (+47.62%)
Mutual labels:  tcp, udp
server-framework
纯C的分布式服务器框架通用模板,跨平台,模块动态加载,tcp/可靠UDP,协程RPC,日志,集群建立
Stars: ✭ 24 (+14.29%)
Mutual labels:  tcp, udp
moss
Reliable and Fast UDP Connections
Stars: ✭ 37 (+76.19%)
Mutual labels:  udp, quic

Mocket

Build Status Join the chat at https://gitter.im/_mocket/Lobby

Lightweight, Typesafe, Reliable, Guaranty delivery, Ordered, High performant java nio sockets build 
on top of udp.

Download

  • Use jitpack as repository
  • Add mocket to dependencies

As shown below:

  1. Maven
<project>
...
    <repositories>
    ...
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
</project>
    <dependencies>
        ...
        <dependency>
            <groupId>com.github.Nishant-Pathak</groupId>
            <artifactId>mocket</artifactId>
            <version>v1.0</version>
        </dependency>
    </dependencies>
  1. Gradle
    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
    dependencies {
        compile 'com.github.Nishant-Pathak:mocket:v1.0'
    }

Simple Server

To build server:

   ServerBuilder<byte []> serverBuilder = new ServerBuilder<byte []>()
        .port(serverPort);
   Server<byte[]> server = serverBuilder.build();

To read:

    while (true) {
      // blocking read
      Pair<SocketAddress, byte[]> readBytes = server.read();
    }

To write:

    // write to server
    server.write(read.getSecond(), read.getFirst());

Write signature:

  /**
   * writed data to the given address
   * @param data to send to addredd
   * @param address of the client connected
   * @throws IOException if error occurs while writing to the socket
   * @throws InterruptedException if write is interrupted
   */
  void write(T data, SocketAddress address) throws IOException, InterruptedException;

Simple Client

To build client:

    ClientBuilder<byte []> builder = new ClientBuilder<byte []>()
        .host("127.0.0.1", 8080);
    Client<byte []> client = builder.build();

To read:

    // blocking read
    byte[] data = client.read();

To write:

   client.write(data);

Write signature:

  /**
   * write object of type T on the wire
   * it used @{@link com.network.mocket.handler.MocketStreamHandler} to parse the object
   * @param data object to send on wire to the server.
   * @throws IOException if error occurs while writing to the socket
   * @throws InterruptedException if write is interrupted
   */
  void write(T data) throws IOException, InterruptedException;

To write custom mapper

Implement java interface and add it to the client and server builder as

        builder.addHandler(new MyCustomHandler())
public interface MocketStreamHandler<P> {
  /**
   * Used to encode object to byte stream
   * @param in inout object of tye {P}
   * @return byte array representing object
   * @throws ParseException throws if fails to encode or decode
   */
  byte [] encode(P in) throws ParseException;

  /**
   * Used to decode bytestream to object
   * @param out inout object of tye {P}
   * @return byte array representing object
   * @throws ParseException throws if fails to encode or decode
   */
  P decode(byte [] out) throws ParseException;
}

Example

Sample server client can be found here example.

Android App Demo

Mocket android app

Use Case

  1. Service-Service communication inside data center.
  2. Use in android app for better performance in flaky networks.
  3. Use in senser based Android things device to push* periodic data to the server.

*Some gateways might block UDP traffic.

Next Milestone

  1. Add ssl support.
  2. Have support for TCP.
  3. Multipart TCP support.

Contributing

I am more than happy to accept external contributions to the project in the form of feedback, bug reports and even better - pull requests :)

If you would like to submit a pull request, please make an effort to follow the guide in CONTRIBUTING.md.

License

Copyright (C) 2016 - 2017 Nishant Pathak

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].