File: NormFileSend.java

package info (click to toggle)
norm 1.5.9%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,680 kB
  • sloc: cpp: 123,494; xml: 7,536; tcl: 5,460; makefile: 3,442; python: 1,898; java: 1,750; ansic: 642; sh: 21; csh: 8
file content (44 lines) | stat: -rw-r--r-- 1,188 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.nio.ByteBuffer;

import mil.navy.nrl.norm.NormEvent;
import mil.navy.nrl.norm.NormInstance;
import mil.navy.nrl.norm.NormNode;
import mil.navy.nrl.norm.NormSession;
import mil.navy.nrl.norm.enums.NormEventType;

/**
 * Example code to send a file to the NormFileRecv example.
 *
 * @author Jason Rush
 */
public class NormFileSend {
  public static void main(String[] args) throws Throwable {
    if (args.length != 1) {
      System.err.println("Usage: NormFileSend <filename>");
      return;
    }

    NormInstance instance = new NormInstance();

    NormSession session = instance.createSession("224.1.2.3", 6003,
        NormNode.NORM_NODE_ANY);
    session.startSender(1, 1024 * 1024, 1400, (short)64, (short)16);

    // Enqueue some data
    ByteBuffer byteBuffer = ByteBuffer.allocateDirect(1024);
    session.dataEnqueue(byteBuffer, 0, 1024);

    // Enqueue a file
    session.fileEnqueue(args[0]);

    NormEvent event;
    while ((event = instance.getNextEvent()) != null) {
      NormEventType eventType = event.getType();
      System.out.println(eventType);
    }

    session.stopSender();
    session.destroySession();
    instance.destroyInstance();
  }
}