OpenCores
URL https://opencores.org/ocsvn/udp_ip_stack/udp_ip_stack/trunk

Subversion Repositories udp_ip_stack

[/] [udp_ip_stack/] [trunk/] [sw/] [UDPTestStream.java] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 pjf
package com.pjf;
2
 
3
import java.io.IOException;
4
import java.net.SocketException;
5
import java.net.UnknownHostException;
6
 
7
public class UDPTestStream {
8
        private UDPCxn cxn;
9
        private Listener listener;
10
 
11
        class Listener extends Thread {
12
 
13
                @Override
14
                public void run() {
15
                        byte[] rep;
16
                        while (true) {
17
                                try {
18
                                        rep = cxn.rcv();
19
                                        String reply = new String(rep);
20
                                        System.out.println("Got [" + reply + "]");
21
                                } catch (IOException e) {
22
                                        e.printStackTrace();
23
                                }
24
                        }
25
                }
26
        }
27
 
28
        public UDPTestStream() throws SocketException, UnknownHostException {
29
                cxn = new UDPCxn("192.168.5.9");
30
                listener = new Listener();
31
                listener.start();
32
        }
33
 
34
        public void go() throws IOException, InterruptedException {
35
                String fix1 = "1=45~34=";
36
                String fix2 = "~18=23~";
37
                for (int price=225; price>=150; price--) {
38
                        StringBuffer fixmsg = new StringBuffer(fix1);
39
                        fixmsg.append(Integer.toString(price));
40
                        fixmsg.append(fix2);
41
                        System.out.println("Sending price tick " + price);
42
                        cxn.fixSend(fixmsg.toString(), 2000, false);
43
                }
44
                Thread.sleep(2000);
45
        }
46
 
47
 
48
        public static void main(String[] args) {
49
                UDPTestStream ut;
50
                try {
51
                        ut = new UDPTestStream();
52
                        ut.go();
53
                } catch (Exception e) {
54
                        e.printStackTrace();
55
                }
56
        }
57
 
58
 
59
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.