python twisted server with C# client -
i have python twisted tcp server transfer data code :
self.transport.write("true") it transfers string "true".
and plan in c# client code :
byte[] rba = new byte[tcpclnt.receivebuffersize]; stm.read (rba, 0, (int)tcpclnt.receivebuffersize); i both tried utf8 , default(ascii) encode convert string :
string returndata = encoding.utf8.getstring (rba); and
string returndata = encoding.default.getstring (rba); and tried :
if ( returndata == "true" ) but doesn't equal returndata "true" , have no idea why ?
can me understand ?
byte[] rba = new byte[tcpclnt.receivebuffersize]; var len=stm.read (rba, 0, (int)tcpclnt.receivebuffersize); string returndata = encoding.utf8.getstring (rba,len); you decoding entire buffer rather 4 bytes got. stm.read should return 4, can use in getstring tell stop after 4.
alternatively, can too:
var returndata = stm.readtoend();
Comments
Post a Comment