StahlWorks Technologies
Products DView SFK Downloads Support Company


How to do things
AI Noob vs. Pro

List biggest files
List newest files
Show subdir sizes
Search in files
Replace word in files
List dir differences
Send files in LAN

Free Open Source:

Swiss File Knife

a command line
multi function tool.

Depeche View
Source Research
First Steps

windows GUI
automation

command line
file encryption

free external tools,
zero install effort,
usb stick compliant:

cpp sources

articles

Supersonic Text File Search - Free Download

Java code example for sending UDP network text.

Send plain or colored UDP network text, then receive and view it instantly with a Freeware tool for Windows and Linux/Mac.

/*
 Example how to send UDP text in Java.
  See also: sfk netlog.
 - copy this to a file netlog.java
 - javac netlog.java
  - run: dview -net
 under Linux/Mac: wine dview.exe -net -linux &
 - java netlog
*/
import java.io.*;
import java.net.*;
public class netlog
{
 public static DatagramSocket clSocket = null;
 public static InetAddress clAddress = null;
 public static int iClPort = -1;
 static int iClRequest = 1;
 public static void init(String sHost, int iPort) throws Throwable
 {
 clAddress = InetAddress.getByName(sHost);
 iClPort = iPort;
 clSocket = new DatagramSocket();
 }
 public static void log(String sTextIn) throws Throwable
 {
 String sText = sTextIn+"\n";
 // change all [red] to compact color codes \x1Fr
 byte[] abData1 = sText.getBytes();
 int iSize1 = abData1.length;
 byte[] abData2 = new byte[iSize1+100];
 // keep 100 bytes space for header
 int i2=100;
 for (int i1=0; i1<iSize1;)
 {
 if (abData1[i1]=='[') {
 i1++;
 if (i1>=iSize1)
 break;
 abData2[i2++] = (byte)0x1F;
 abData2[i2++] = abData1[i1++];
 while (i1<iSize1 && abData1[i1]!=']')
 i1++;
 if (i1<iSize1)
 i1++;
 } else {
 abData2[i2++] = abData1[i1++];
 }
 }
 int iTextSize = i2-100;
 // add sfktxt header before text
 String sHead = ":sfktxt:v100,req"+iClRequest+",cs1\n\n";
 iClRequest++;
 byte abHead[] = sHead.getBytes();
 int iHeadLen = abHead.length;
 for (int i=0; i<iHeadLen; i++)
 abData2[100-iHeadLen+i] = abHead[i];
 int iStartOff = 100-iHeadLen;
 int iFullSize = iHeadLen+iTextSize;
 DatagramPacket packet = new DatagramPacket(abData2,
 iStartOff, iFullSize, clAddress, iClPort);
 clSocket.send(packet);
 }
 public static void main(String args[]) throws Throwable
 {
 netlog.init("localhost", 21323);
 netlog.log("[Red]Foo[def] and [Blue]bar[def] went "
 +"to the [Green]zoo[def].");
 }
}


imprint / impressum

AltStyle によって変換されたページ (->オリジナル) /