Socket Reconnection Cycle Algorithm, help, please!

teixeira

Regular
Joined
Apr 5, 2005
Messages
94
Location
LEIRIA-PORTUGAL
Hi,

I have a printer connected to the network, and i want to monitorize all its status.
I wanna know when it is online or down, and i made a couple of code to do it but it doesn't work at all as it should be.

I need to start my application, check if the printer is ONLINE ( i'm using a ping ) after ping == sucessfull i make a socket connect asynchronously with BeginReceive(); in a specific port where printer sends its status (9100 traditional port) and in the function that receives the data from printer and treat it to show some particular printer information. when socket raises an error of connection i make an Asynchronous Ping and i wait its echo to be sucessfull, and after that i reconnect again the socket.

In theory its works but in practice, sockets have some particullar behaviours that doesn't allow me to make this recconnect cycle sucessfully.

Does anyone as some piece of code that allows me to trace printer connection, just 4 steps:
1-Connect
2-Receive Data From Printer
3-Reconnect Socket
4.... receive again Data

TIA
Tiago Teixeira
 
Back
Top