Results 1 to 1 of 1
  1. #1
    passer-by is offline Member
    Join Date
    Jul 2011
    Posts
    3
    Rep Power
    0

    Default network protocol

    I am trying to write a server program that collects data from devices. This program is supposed to replace
    the old one (we buy it abroad). But I don't have any documentation the way server program communicates with devices
    In order to understand the exchange protocol I use Wireshark sniffer.

    A Proper protocol from wireshark

    Client -> Syn
    Server -> Ack Syn
    Client -> Ack syn
    Client -> <INI> string
    Server -> ACK string
    Client -> <RDY>
    Server -> 0B0B11040101000101050000 string
    Client -> <ACK>01
    Client -> Data
    ...

    But in my way after recieving <RDY> string server and client exchenges by the ack messages. And client sends <RDY> once again. Is it possible to avoid this exchanging?

    This is a cutting of my code:
    Java Code:
    try{
                String inputLine;                                              //Here strings from client will be stored
                String ack = "ACK" + "\r";                                     //answer from server to <INI> line from wcl
                String ackAdd = "\r\n";
                String hex = "0B0B11040101000101050000";                       //read index from client
    
                /*Get the input and output I/O steams from socket
                * */
    
                BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                OutputStream out = socket.getOutputStream();
                DataOutputStream dos = new DataOutputStream(out);
    while ((inputLine = in.readLine()) != null){
                    if((inputLine.toUpperCase()).contains("<INI>")){
                        jta.append("Wavecell with IP" + socket.toString() + " tries to connect to server" + inputLine + "\n");
    
                        dos.writeBytes(ack);                             //send ack to <INI> command from wcl
                        dos.flush();
                        dos.writeBytes(ackAdd);
                        dos.flush();
    
                    }else if((inputLine.toUpperCase()).contains("<RDY>")){
                        dos.writeBytes(hex);                             //now we can request the data index
                        dos.flush();
                        dos.write(ackAdd);
                        dos.flush();
                    }else if ((inputLine.toUpperCase()).contains("<ANS>")){
                        dos.writeBytes("0404010000");
                        dos.flush();
                        dos.writeBytes();
                        dos.flush();
                    }
                } 
                
                out.close();
                dos.close();
                socket.close();
    
            }catch (IOException ex){
                logger.log(Level.SEVERE, "Problems with getting I/O streams ");
                System.exit(-1);
            }
    }
    Last edited by passer-by; 08-09-2011 at 08:38 AM.

Similar Threads

  1. JNLP(Java Network Launching Protocol)
    By mitra in forum Networking
    Replies: 0
    Last Post: 07-28-2011, 01:48 PM
  2. Replies: 7
    Last Post: 05-02-2010, 10:35 PM
  3. unsupported protocol
    By shiva in forum New To Java
    Replies: 1
    Last Post: 04-09-2009, 09:20 AM
  4. New Protocol?
    By lada.r in forum Networking
    Replies: 0
    Last Post: 11-06-2007, 09:13 PM
  5. how to use SIP protocol
    By katie in forum Advanced Java
    Replies: 1
    Last Post: 08-06-2007, 10:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •