Ping in VB.Net

  • Thread starter Thread starter Rudolf
  • Start date Start date
Hi,
Ok Ok Ok
But then minimal
FCNHTA
I will real start thinking(working) for it after my HKW (is on the route).
Cor
 
Hi Rudolf,

I'm sorry for kept you for so long. I've done some research on this issue
and wrote a short sample. Please define the WSADATA structure like the
following:

Private Const WSADESCRIPTION_LEN = 256

<StructLayout(LayoutKind.Sequential)> _
Public Structure WSADATA

Public wVersion As Short
Dim wHighVersion As Short

<MarshalAs(UnmanagedType.ByValTStr, sizeConst:=WSADESCRIPTION_LEN +
1)> _
Public szDescription As String
<MarshalAs(UnmanagedType.ByValTStr, sizeConst:=WSADESCRIPTION_LEN +
1)> _
Public szSystemStatus As String
Public iMaxSockets As Integer
Public iMaxUdpDg As Integer
Public lpVenderInfo As IntPtr

End Structure

Private Declare Function WSAStartup Lib "wsock32" (ByVal
wVersionRequired As Integer, ByRef lpWSADATA As WSADATA) As Integer

In your codes you can use it as:

Dim Data As New WSADATA
If WSAStartup(&H201, Data) = 0 Then
'Codes of your logic
End If

HTH

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Rudolf" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Ping in VB.Net
| Date: Wed, 24 Sep 2003 15:37:59 +0200
| Lines: 82
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 165.165.25.85
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:140910
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| I attempted to do an upgrade of the vb6 code using winapi calls but this
| also does not work.
|
| When calling the WSAStartup function (in SocketsInitialize) I get a stack
| overflow error. I tried different variations of the WSADATA structure but
it
| does not help.
|
| The following is the declarations:
|
| Private Structure WSADATA
| Dim wVersion As Short
| Dim wHighVersion As Short
| <VBFixedArray(MAX_WSADescription)> Dim szDescription() As Byte
| <VBFixedArray(MAX_WSASYSStatus)> Dim szSystemStatus() As Byte
| Dim wMaxSockets As Integer
| Dim wMaxUDPDG As Integer
| Dim dwVendorInfo As Integer
|
| Public Sub Initialize()
| ReDim szDescription(MAX_WSADescription)
| ReDim szSystemStatus(MAX_WSASYSStatus)
| End Sub
| End Structure
| Const WS_VERSION_REQD As Integer = &H101s
|
| Private Declare Function WSAStartup Lib "wsock32" (ByVal wVersionRequired
As
| Integer, ByRef lpWSADATA As WSADATA) As Integer
|
| When called like this:
|
| Dim WSAD As WSADATA
| WSAD.Initialize()
| If WSAStartup(WS_VERSION_REQD, WSAD) = IP_SUCCESS Then ...
|
| It gives a stack overflow error.
|
| What must the declarations look like to word?
|
| thanks
|
| Rudolf
|
| | > I want to build a ping type monitor app. I've done it before for VB 6
but
| > now want to do it completely over in VB.net. I did find some .Net
samples
| > but they are using raw sockets which is not allowed/blocked on the
machine
| > it is running on. The old ping.exe util does still work on it though.
| >
| > Only if there is no other way will I try to use winapi calls again.
| >
| > thanks
| >
| > Rudolf
| >
| > | > > Hello,
| > >
| > > > > http://www.csharphelp.com/archives2/archive296.html
| > > > > http://www.c-sharpcorner.com/network/ping.asp
| > > > >
| > > > | using only VB.Net?
| > > > ?!?
| > > > ;-)
| > > > Do you know someone who can put that rewritten in VB
| > > > after his Whois example?
| > >
| > > What exactly do you want to do? Do you want to convert the code to
| VB.NET?
| > >
| > > --
| > > Herfried K. Wagner
| > > MVP · VB Classic, VB.NET
| > > http://www.mvps.org/dotnet
| > >
| > >
| >
| >
|
|
|
 
Thanks, I'll have a look at it again.

Rudolf

-----Original Message-----
Hi Rudolf,

I'm sorry for kept you for so long. I've done some research on this issue
and wrote a short sample. Please define the WSADATA structure like the
following:

Private Const WSADESCRIPTION_LEN = 256

<StructLayout(LayoutKind.Sequential)> _
Public Structure WSADATA

Public wVersion As Short
Dim wHighVersion As Short

<MarshalAs(UnmanagedType.ByValTStr,
sizeConst:=WSADESCRIPTION_LEN +
1)> _
Public szDescription As String
<MarshalAs(UnmanagedType.ByValTStr,
sizeConst:=WSADESCRIPTION_LEN +
1)> _
Public szSystemStatus As String
Public iMaxSockets As Integer
Public iMaxUdpDg As Integer
Public lpVenderInfo As IntPtr

End Structure

Private Declare Function WSAStartup Lib "wsock32" (ByVal
wVersionRequired As Integer, ByRef lpWSADATA As WSADATA) As Integer

In your codes you can use it as:

Dim Data As New WSADATA
If WSAStartup(&H201, Data) = 0 Then
'Codes of your logic
End If

HTH

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

--------------------
| From: "Rudolf" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: Ping in VB.Net
| Date: Wed, 24 Sep 2003 15:37:59 +0200
| Lines: 82
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.languages.vb
| NNTP-Posting-Host: 165.165.25.85
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl! tk2msftngp13.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:140910
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb
|
| I attempted to do an upgrade of the vb6 code using winapi calls but this
| also does not work.
|
| When calling the WSAStartup function (in
SocketsInitialize) I get a stack
 
Back
Top