java - Socket Host Echo not 'responding' -
i having weird problem socket programming picked recently. understand socket can used client communicate host. project requires iso8583 well. got working code , modifying work on own testing host.
all , code work 1 problem faced got no response @ all. request sent computer host works. host displays correct messages , sends response computer. not know why @ point, app hang there. in debug mode, executing line (which show line executing) continuously without returning value. code below. quite messy , attempting lots of methods of trying response value.
byte datasmall[] = {0x00, 0x43, 0x60, 0x00, 0x02, 0x00, 0x00, 0x08, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, (byte) 0xc0, 0x00, 0x00, 99, 0x00, 0x00, 0x00, 0x02, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31}; try { socket echosocket = new socket("ip address", port number); objectoutputstream os = new objectoutputstream(echosocket.getoutputstream()); string responseline; client client = new client(echosocket); thread reader = new thread(client, "j8583-client"); printwriter pw = new printwriter(os, true); reader.start(); os.writeobject(datasmall); os.flush(); objectinputstream ois = new objectinputstream(echosocket.getinputstream()); //convert objectinputstream object string string message = (string) ois.readobject(); // continuous execution system.out.println(message); system.out.println("waiting response"); bufferedreader in = new bufferedreader(new inputstreamreader( echosocket.getinputstream())); responseline = in.readline().tochararray().tostring(); system.out.println("still waiting response"); system.out.println(responseline); os.close(); in.close(); echosocket.close(); client.stop(); reader.interrupt(); i have tried .readobject() , .readline() response output , both perform same problem. executing no end it. unfortunately out of ideas on how should approach this. important response test host. appreciate guys can give. in advance.
if server you're talking isn't written in java or doesn't use object serialization, code cannot possibly work. don't see reason here use object streams. try actual socket streams.
Comments
Post a Comment