Jump to content
Xtreme .Net Talk

Socket Reconnection Cycle Algorithm, help, please!


Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...