KirillBelov/ LTP

Length Transfer Protocol

Contributed by: Kirill Belov

Installation Instructions

To install this paclet in your Wolfram Language environment, evaluate this code:
PacletInstall["KirillBelov/LTP"]


To load the code after installation, evaluate this code:
Needs["KirillBelov`LTP`"]

Examples

Basic Examples (2) 

Create server:

In[1]:=
Once[serverSocket = CSocketOpen[8080]];
socketHandler = CSocketHandler[];

ltpHandler = LTPHandler[];

socketHandler["DefaultHandler"] = Function[Echo[#];]; socketHandler["Accumulator", "LTP"] = LTPPacketQ -> LTPPacketLength;
socketHandler["Handler", "LTP"] = LTPPacketQ -> ltpHandler;

ltpHandler["Responsible"] = False;
ltpHandler["Deserializer"] = ByteArrayToString;
ltpHandler["Handler"] = Echo;

Once[listener = SocketListen[serverSocket, socketHandler]];

Connect to the server:

In[2]:=
Once[clientSocket = CSocketConnect[8080]];
LTPSend[clientSocket, "hello", "Serializer" -> StringToByteArray];

Scope (1) 

Using Java client:

In[3]:=
Get["JLink`"]; 
LTPClientClass = LoadJavaClass["kirillbelov.ltp.LTPClient"]; 
javaLTPClient = JavaNew[LTPClientClass, 8080]; 
Block[{send}, javaLTPClient @ send["hello from java"]];

Publisher

Kirill Belov

Disclosures

Compatibility

Wolfram Language Version 14

Version History

  • 1.0.0 – 11 March 2025

License Information

MIT License

Paclet Source