By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,857 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,857 IT Pros & Developers. It's quick & easy.

System.net.sockets (VB6'er - new to .Net)

P: n/a
Hey all,

I'm a casual/hobby programmer who's always used VB6. I'm trying out VB 2008
express edition now. I understand a few basic concepts about .Net, but am
doing this by myself with no more help than Google.

I dont want to do anything fancy, just connect 2 machines to chat and play
chess. I used the Winsock control in VB6, and have spent the last 4 hours
or so googling to the conclusion that it's been replaced (?) with namespace
System.Net.Sockets...

Every tutorial/help file I've found online has looked as if you needed 6
months .Net experience before you could even BEGIN to understand it. I've
gotten this far, but whenever I run this code the program freezes up until
it gives a 'no response' error (not expecting a response at this point in
time). Is there any .Net equivalent to DoEvents() ?

Thanks in advance for any help/advice :0)

On Error GoTo erra

Dim hostEntry As IPHostEntry = Nothing
Dim server As String = txtIP.Text
Dim port As Integer = Int(txtPort.Text)

' Get host related information.
hostEntry = Dns.GetHostEntry(server)

' Loop through the AddressList to obtain the supported
AddressFamily. This is to avoid
' an exception that occurs when the host IP Address is not
compatible with the address family
' (typical in the IPv6 case).
Dim address As IPAddress

For Each address In hostEntry.AddressList
Dim endPoint As New IPEndPoint(address, port)
Dim sck As New Socket(endPoint.AddressFamily, SocketType.Stream,
ProtocolType.Tcp)
sck.Connect(endPoint)
Next address
erra:
errMsg(Err.Number & " - " & Err.Description)

Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"com64" <br****@orcon.net.nzwrote in message
news:63**********************************@microsof t.com...
Every tutorial/help file I've found online has looked as if you needed 6
months .Net experience before you could even BEGIN to understand it. I've
gotten this far, but whenever I run this code the program freezes up until
it gives a 'no response' error (not expecting a response at this point in
time). Is there any .Net equivalent to DoEvents() ?
I don't know if it applies to your code situation.

System.Windows.Forms.Application.DoEvents()

Jun 27 '08 #2

P: n/a

Aside from the sockets stuff, you might want to forget everything you
ever learned about On Error Goto/Resume and start using SEH
(Structured Exception Handling):
http://www.dotnetjunkies.ddj.com/Tut...5C231BF75.dcik

As for the evil DoEvents statement, this was covered in the recent
recent thread with the subject "Long Process".

Regards,

Joergen Bech

On Mon, 26 May 2008 22:05:03 +1200, "com64" <br****@orcon.net.nz>
wrote:
>Hey all,

I'm a casual/hobby programmer who's always used VB6. I'm trying out VB 2008
express edition now. I understand a few basic concepts about .Net, but am
doing this by myself with no more help than Google.

I dont want to do anything fancy, just connect 2 machines to chat and play
chess. I used the Winsock control in VB6, and have spent the last 4 hours
or so googling to the conclusion that it's been replaced (?) with namespace
System.Net.Sockets...

Every tutorial/help file I've found online has looked as if you needed 6
months .Net experience before you could even BEGIN to understand it. I've
gotten this far, but whenever I run this code the program freezes up until
it gives a 'no response' error (not expecting a response at this point in
time). Is there any .Net equivalent to DoEvents() ?

Thanks in advance for any help/advice :0)

On Error GoTo erra

Dim hostEntry As IPHostEntry = Nothing
Dim server As String = txtIP.Text
Dim port As Integer = Int(txtPort.Text)

' Get host related information.
hostEntry = Dns.GetHostEntry(server)

' Loop through the AddressList to obtain the supported
AddressFamily. This is to avoid
' an exception that occurs when the host IP Address is not
compatible with the address family
' (typical in the IPv6 case).
Dim address As IPAddress

For Each address In hostEntry.AddressList
Dim endPoint As New IPEndPoint(address, port)
Dim sck As New Socket(endPoint.AddressFamily, SocketType.Stream,
ProtocolType.Tcp)
sck.Connect(endPoint)
Next address
erra:
errMsg(Err.Number & " - " & Err.Description)
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.