Ping OpenNet question

N

news.microsoft.com

I need to try to ping a QL220 Plus Zebra printer set up as a wireless
network printer before I try to print to it. I want a quick way to figure
out if the printer at a certain IP is awake or sleeping etc but in any case
try to determine whether I can print to it or not from my MC70 app.
I've looked at the .Net.NetworkInformation.Ping.Send which returns a
PingReply but don't really know how this works and whether this is the best
code for my purposes...
Any suggestions?

TIA
Harry
 
A

Arun

Harry,
Send an simple ICMP request to find out the printer is available for
communication.
You can use IcmpSendEcho
http://msdn2.microsoft.com/en-us/library/ms927415.aspx

I think OpenNetCF also does the same.
Refer here too
http://groups.google.com/group/micr...74388?lnk=gst&q=IcmpSendEcho#dc3234d9d6774388

ICMP will not work with ActiveSync, and if you want to validate with
IPAddress and a port number, try with this code

public static bool IsConnectionEstablished(IPAddress ipAddress, int
port)
{
bool connectStatus = false;
Socket m_ClientSocket = null;
try
{
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress,
port);
m_ClientSocket = new
Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
m_ClientSocket.Connect(ipEndPoint);

connectStatus = m_ClientSocket.Connected;
}
return connectStatus;
}

Hope this helps,
Cheers,
Arun.
 
N

news.microsoft.com

Arun,

Thanks for the links....is there anything in CF to do this? These look like
CE functions - any managed code for this or wrapped code?

Guess I really just need to see if the printer is available - it'd look like
a network printer weith IP.

thanks
Harry
Harry,
Send an simple ICMP request to find out the printer is available for
communication.
You can use IcmpSendEcho
http://msdn2.microsoft.com/en-us/library/ms927415.aspx

I think OpenNetCF also does the same.
Refer here too
http://groups.google.com/group/micr...74388?lnk=gst&q=IcmpSendEcho#dc3234d9d6774388

ICMP will not work with ActiveSync, and if you want to validate with
IPAddress and a port number, try with this code

public static bool IsConnectionEstablished(IPAddress ipAddress, int
port)
{
bool connectStatus = false;
Socket m_ClientSocket = null;
try
{
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress,
port);
m_ClientSocket = new
Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
m_ClientSocket.Connect(ipEndPoint);

connectStatus = m_ClientSocket.Connected;
}
return connectStatus;
}

Hope this helps,
Cheers,
Arun.
 
N

news.microsoft.com

That's what I've used with some success:
Private Function CheckConnection() As
OpenNETCF.Net.NetworkInformation.PingReplyDim conn As New
OpenNETCF.Net.NetworkInformation.Ping

Try

Return conn.Send("192.168.0.100", 10)

Catch ex As Exception



End Try

End Function

Thing is when I execute the call and the printer is turned off, the app just
hangs.....figured the timeout was in milliseconds first yet the param is an
integer.

I want it to quickly check - like a quick ping and then if failed drop and
teturn false quickly - but it just kinda hangs up the first ping if false
and subsequent hits are fast.

that second param, does it control how quickly the PingReply is returned?

Harry

The OpenNETCF SDF [1] does have Ping capabilities in the
NetworkInformation namespace. It would work identically to the sample on
MSDN that Arun pointed to.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com



[1] www.opennetcf.com/sdf

news.microsoft.com said:
Arun,

Thanks for the links....is there anything in CF to do this? These look
like CE functions - any managed code for this or wrapped code?

Guess I really just need to see if the printer is available - it'd look
like a network printer weith IP.

thanks
Harry
Harry,
Send an simple ICMP request to find out the printer is available for
communication.
You can use IcmpSendEcho
http://msdn2.microsoft.com/en-us/library/ms927415.aspx

I think OpenNetCF also does the same.
Refer here too
http://groups.google.com/group/micr...74388?lnk=gst&q=IcmpSendEcho#dc3234d9d6774388

ICMP will not work with ActiveSync, and if you want to validate with
IPAddress and a port number, try with this code

public static bool IsConnectionEstablished(IPAddress ipAddress, int
port)
{
bool connectStatus = false;
Socket m_ClientSocket = null;
try
{
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress,
port);
m_ClientSocket = new
Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
m_ClientSocket.Connect(ipEndPoint);

connectStatus = m_ClientSocket.Connected;
}
return connectStatus;
}

Hope this helps,
Cheers,
Arun.
 
M

Mortimer

news.microsoft.com said:
That's what I've used with some success:
Private Function CheckConnection() As
OpenNETCF.Net.NetworkInformation.PingReplyDim conn As New
OpenNETCF.Net.NetworkInformation.Ping

Try

Return conn.Send("192.168.0.100", 10)

Catch ex As Exception



End Try

End Function

Thing is when I execute the call and the printer is turned off, the app just
hangs.....figured the timeout was in milliseconds first yet the param is an
integer.

I want it to quickly check - like a quick ping and then if failed drop and
teturn false quickly - but it just kinda hangs up the first ping if false
and subsequent hits are fast.

that second param, does it control how quickly the PingReply is returned?

Harry

The OpenNETCF SDF [1] does have Ping capabilities in the
NetworkInformation namespace. It would work identically to the sample on
MSDN that Arun pointed to.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com



[1] www.opennetcf.com/sdf

news.microsoft.com said:
Arun,

Thanks for the links....is there anything in CF to do this? These look
like CE functions - any managed code for this or wrapped code?

Guess I really just need to see if the printer is available - it'd look
like a network printer weith IP.

thanks
Harry
Harry,
Send an simple ICMP request to find out the printer is available for
communication.
You can use IcmpSendEcho
http://msdn2.microsoft.com/en-us/library/ms927415.aspx

I think OpenNetCF also does the same.
Refer here too
http://groups.google.com/group/micr...74388?lnk=gst&q=IcmpSendEcho#dc3234d9d6774388

ICMP will not work with ActiveSync, and if you want to validate with
IPAddress and a port number, try with this code

public static bool IsConnectionEstablished(IPAddress ipAddress, int
port)
{
bool connectStatus = false;
Socket m_ClientSocket = null;
try
{
IPEndPoint ipEndPoint = new IPEndPoint(ipAddress,
port);
m_ClientSocket = new
Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
m_ClientSocket.Connect(ipEndPoint);

connectStatus = m_ClientSocket.Connected;
}
return connectStatus;
}

Hope this helps,
Cheers,
Arun.


I need to try to ping a QL220 Plus Zebra printer set up as a wireless
network printer before I try to print to it. I want a quick way to
figure
out if the printer at a certain IP is awake or sleeping etc but in any
case
try to determine whether I can print to it or not from my MC70 app.
I've looked at the .Net.NetworkInformation.Ping.Send which returns a
PingReply but don't really know how this works and whether this is the
best
code for my purposes...
Any suggestions?

TIA
Harry
 
M

Mortimer

Did you find a solution to this?
I'm trying something similar using an IP camera, and need to ping it to
check if its powered on or off using CF
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top