c# - Receiving and sending strings over network -


i have send , receive strings on network precise computer (with known ip). wrote following :

void connect() {     eplocal = new ipendpoint(ipaddress.parse(localip), localport);     sck.bind(eplocal);      epremote = new ipendpoint(ipaddress.parse(remoteip), remoteport);     sck.connect(epremote);      byte[] buffer = new byte[1500];     sck.beginreceivefrom(buffer, 0, buffer.length, socketflags.none, ref epremote, new asynccallback(messagecallback), buffer);      console.writeline("connected " + remoteip); }  void sendmessage(string str) {     system.text.asciiencoding enc = new asciiencoding();     byte[] msg = new byte[8000];     msg = enc.getbytes(str);      sck.send(msg); }  void messagecallback(iasyncresult aresult) {     console.writeline("message received");      int size = sck.endreceivefrom(aresult, ref epremote);     if (size > 0)     {         byte[] receiveddata = new byte[1464];         receiveddata = (byte[])aresult.asyncstate;          asciiencoding eencpding = new asciiencoding();         string receivedmessage = eencpding.getstring(receiveddata);         console.writeline("received message:" + receivedmessage);     }      byte[] buffer = new byte[1500];     sck.beginreceivefrom(buffer, 0, buffer.length, socketflags.none, ref epremote, new asynccallback(messagecallback), buffer); } 

although, when call connect() , sendmessage("hello"), have nothing written console showing received message. why happening?


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -