c# - TcpListener doesn't connect/establish a connection -


i'm trying start connection without manualresetevent, it's skip beginacceptsocket telling me press key continue, although manualresetevent succeeded connection client sends me irrelevant bytes.

    static void main(string[] args)     {         tcplistener = new tcplistener(ipaddress.any, 8484);         tcplistener.start();         tcplistener.beginacceptsocket(acceptsocket, tcplistener);     }     private static void acceptsocket(iasyncresult async)     {         new client(tcplistener.endacceptsocket(async));         tcplistener.beginacceptsocket(acceptsocket, null);     } 

for example consider client acceptor incoming bytes.

beginacceptsocket asynchronous; not running on same thread main, , result, program ending before connection received. remedy this, either convert synchronous accept or keep main thread active prevent program closing. recommend read on implications of asynchronous methods before using such methods.

i need see manualresetevent code answer "irrelevant bytes" means nothing me because not know expecting or getting. also, think using manualresetevent while using asynchronous methods in exact same place defeats purpose of using asynchronous methods in first place.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -