sockets - C# Simulate TCP port not responding -


i have proxy server written in c# runs windows service. listens on 127.0.0.1:xxxxx xxxxx can range of ports 53500 up.

the proxy works ports stop responding , when try telnet them says request timed out or did not respond.

i have not been able reproduce problem in development area think has causing beginreceive not called after endreceive. following quote thread symptoms experiencing.

similar problem when using asynchronous communication , there execution path turns out not call beginreceive once previous endreceive completed. makes socket ignorant further data sent remote side.

is there way simulate situation port stops responding. want write code check if port responding before proceeds request. if not responding can remove listener on port , add again. band-aid keep proxy crashing until can determine cause of problem.

i've added logging determine causing ports stop responding.

i'm taking stab in dark, code wrapped in try block?

if block place call endreceive, might eliminate problem.

try{     // processing code }finally{     endreceive()     beginreceive()  } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -