I just bought "Network Programming in .NET with C# and Visual Basic .NET" because of a recommendation here, but I got the book and found out that it's apparently in the wrong version for what I'm using. I'm using Visual Studio 2005 Professional, and I got syntax errors when I tried using some of the code in the book. The book looks like it's exactly what I want except for the incompatibility. Does anyone have any recommendations for books that teach socket and network programming in VB 2005 Thanks.

Book recommendations?
Dave.H
I tried to enter the code to make a Layer 3 network tap. Today, I got it working without the errors I had before. I ran into one problem though, that prevented me from running it, and I don't understand the error.
System.InvalidOperationException was unhandled
Message="Cross-thread operation not valid: Control 'lbPackets' accessed from a thread other than the thread it was created on."
So do you still have this issue What this means is that you are trying to update controls on a form from a
thread that is used to callback your Callback function. If you lookinto MSDN there are specific examples of
how you can fix this.
kkting
socket level. You could work around these issues by looking up
in the msdn. There are no books on 2.0 yet that I know of.
What exactly are the issues you are having
Kevin Farlee
Brice FROMENTIN
Max Iturra
I tried to enter the code to make a Layer 3 network tap. Today, I got it working without the errors I had before. I ran into one problem though, that prevented me from running it, and I don't understand the error.
System.InvalidOperationException was unhandled
Message="Cross-thread operation not valid: Control 'lbPackets' accessed from a thread other than the thread it was created on."
Here's my code:
Imports System
Imports
System.Windows.FormsImports
System.Net.SocketsImports
System.NetImports
System.ThreadingImports
System.textPublic
Class Form1 Public listener As Threading.Thread Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.ClickbtnStart.Enabled =
FalsebtnStop.Enabled =
Truelistener =
New Threading.Thread(New Threading.ThreadStart(AddressOf Run))listener.Start()
End Sub Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.ClickbtnStart.Enabled =
TruebtnStop.Enabled =
False If Not listener Is Nothing Thenlistener.Abort()
listener.Join()
listener =
Nothing End If End Sub Public Sub Run() Dim len_receive_buf As Integer = 4096 Dim len_send_buf As Integer = 4096 Dim receive_buf() As Byte = New Byte(len_receive_buf) {} Dim send_buf() As Byte = New Byte(len_send_buf) {} Dim cout_receive_bytes As Integer Dim socket As Net.Sockets.Socket = New _Net.Sockets.Socket(Net.Sockets.AddressFamily.InterNetwork, _
Net.Sockets.SocketType.Raw, Net.Sockets.ProtocolType.IP)
socket.Blocking =
False Dim IPHost As Net.IPHostEntry = _Net.Dns.GetHostByName(Net.Dns.GetHostName())
socket.Bind(
New _Net.IPEndPoint(Net.IPAddress.Parse _
(IPHost.AddressList(0).ToString()), 0))
socket.SetSocketOption(Net.Sockets.SocketOptionLevel.IP, _
Net.Sockets.SocketOptionName.HeaderIncluded, 1)
Dim bIN As Byte() = New Byte() {1, 0, 0, 0} Dim bOUT As Byte() = New Byte() {0, 0, 0, 0} Dim SIO_RCVALL As Integer = &H98000001 Dim ret_code As Integer = socket.IOControl _(SIO_RCVALL, bIN, bOUT)
Do Dim ar As IAsyncResult = socket.BeginReceive _(receive_buf, 0, _
len_receive_buf, Net.Sockets.SocketFlags.None,
Nothing, Me)cout_receive_bytes = socket.EndReceive(ar)
Receive(receive_buf, cout_receive_bytes)
Loop End Sub Public Sub Receive(ByVal buf As Byte(), ByVal len As Integer) If buf(9) = 6 ThenlbPackets.Items.Add(Encoding.ASCII.getstring _
(buf).replace(Chr(0),
" ")) End If End SubEnd
Classnizzy8
William R