title: Sending data via the network
body: <p>I would like to create a program that will emulate a device connected to the network and send signals through a specific port.</p>
  
  <p>The device is connected to the network and sends data through a port. On the server(or computer) I have running the CPR Manager v.4.3.0.1 from Lantronix that will associate the IP:PORT to a virtual COM port on the computer. I have a java program that listens to the COM ports and performs an action, this works great with the device. </p>
  
  <p>I tried writing a java app using the Socket class to perform the connection but it was un successful, on the CPR side it only registers a Disconnect when the very first line is executed:</p>
  
  <pre><code>Socket socket = new Socket("192.168.1.160", 8888);
  </code></pre>
  
  <p>I also tried it using the UDP method and no message whats so ever is recorded.</p>
  
  <p>Any help would be greatly appreciated. Also if there is no possible solution for Java then any other language would do fine.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here is the Java code where I am attempting to send the data</p>
  
  <pre><code>  public static void main(String[] args){
      try{
        Socket socket = new Socket("192.168.1.160", 8888);
  
        if(socket.isConnected()){
            System.out.println("It is connected.");
            socket.setKeepAlive(true);
            System.out.println(socket.isBound());
        }else{
            System.out.println("It is not connected.");
        }
        PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
        BufferedReader in =
                new BufferedReader(
                          new InputStreamReader(socket.getInputStream()));
        String msg = "32";
        for(int i = 0; i &lt; 50; i++){
            out.println(msg);
        }
  
        //Receive a reversed message
        msg = in.readLine();
        System.out.println("Server : " + msg);
  
      }catch(Exception ioe){
        ioe.printStackTrace();
      }
    }
  </code></pre>
  
  <p>Thanks.</p>
  
  <p><strong>Update</strong></p>
  
  <p>I got in contact with some people of the devices and they showed me that there is a way to communicate straight via a TCP/IP connection sending there ASCII Command Protocols. This would allow more in depth control at every level. </p>
  
  <p>So, now I am writing a java program that can communicate using these protocols.
  Because, I am not using a comm port anymore I am tying to emulate the baud rate, data bits, stop bit stuff. I will post when I have some that works.</p>
  
  <p>Thanks for all the help.</p>