hi had working middle-ware program using c#. program sends request website , pulls data there . getting error , know since website url has been changed .
before url : ip:port url has been changed : ip:port/nugaweb
how can change program request go new url . adding buffer , not sure if can .
error :
system.net.sockets.socketexception: established connection aborted software in host machine @ system.net.sockets.socket.receive(byte[] buffer, int32 offset, int32 size, socketflags socketflags) @ system.net.sockets.socket.receive(byte[] buffer) @ myrfid.connsocket.getresponse(int32 protocol, string sendstring) in d:\birth_daytestnewserver\myrfid\connsocket.cs:line 87}
connection.cs
class connsocket { public const int overhit_add_user = 100; public const int overhit_get_average_of_age= 101; public const int overhit_write_test_result = 102; public const int overhit_user_list = 103; public const int overhit_user_sex= 105; public const string header="ff00"; public const string tailer="/$/$"; private socket clientsocket = null; //public static string ip = "121.158.41.217"; public static string ip = "165.132.221.47"; private byte[] receivedata; private void connection() { try { receivedata=new byte[4096]; clientsocket = new socket(addressfamily.internetwork, sockettype.stream, protocoltype.tcp); //clientsocket.connect(ip, 8090); clientsocket.connect(ip, 8080); } catch (exception ex) { messagebox.show(ex.tostring()); } } public string getresponse(int protocol, string sendstring) { string sendmsg = ""; string recmsg = ""; byte[] send = null; byte[] rec = null; connection(); try { encoding korean = encoding.getencoding("euc-kr"); encoding enc = encoding.ascii; rec=new byte[1024]; //serverstream = clientsocket.getstream(); sendmsg = header + "&" + protocol + "&" + sendstring + tailer; //step3 :sendmsg="" send = new byte[korean.getbytes(sendmsg).length]; //step4 : sendmsg = "ff00&105&eecb0b7e000104e0/$/$" sendmsg becomes "ff00&105&/$/$" , becomes "ff00&101&eecb0b7e000104e0&28/$/$" , "ff00&101&&28/$/$" send=korean.getbytes(sendmsg); //i tried adding check on sendmsg here if (sendmsg == "ff00&105&/$/$") { messagebox.show("card not placed !! place card , please try again "); return null; //system.environment.exit(0); } clientsocket.send(send); int reclen = 0; reclen=clientsocket.receive(rec); recmsg = korean.getstring(rec, 0, reclen); //sw.write(send); /* rec = new byte[1024]; rec=korean.getbytes(sr.readtoend()); */ /* while (!sr.endofstream) { recmsg=recmsg+sr.readline(); } * */ } catch (exception ex) { messagebox.show(ex.tostring()); } /*i tried catch (socketexception e) { if (e.socketerrorcode == wouldblock) { m_socket.blocking = true; m_socket.send(buffer, buffersize, socketflags.none); m_socket.blocking = false; } }*/ { if (clientsocket != null) { clientsocket.close(); clientsocket = null; } } return recmsg; } }
Comments
Post a Comment