Results 1 to 1 of 1
Thread: network protocol
- 08-09-2011, 08:35 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 3
- Rep Power
- 0
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
-
JNLP(Java Network Launching Protocol)
By mitra in forum NetworkingReplies: 0Last Post: 07-28-2011, 01:48 PM -
Server is in a network using an IP, but router in network carries the external IP(www
By lse123 in forum NetworkingReplies: 7Last Post: 05-02-2010, 10:35 PM -
unsupported protocol
By shiva in forum New To JavaReplies: 1Last Post: 04-09-2009, 09:20 AM -
New Protocol?
By lada.r in forum NetworkingReplies: 0Last Post: 11-06-2007, 09:13 PM -
how to use SIP protocol
By katie in forum Advanced JavaReplies: 1Last Post: 08-06-2007, 10:22 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks