|
-
Aug 2nd, 2010, 06:26 AM
#1
Thread Starter
New Member
Recieved TCP packet drops first byte
Hi,
I've been using some code which I found on the net, and have noticed that the first byte is never recieved. Annoyingly, this contains the MAC addresses, which is the bit I want. Can anyone help? Below is the relevant snippits:
Public Sub [Start]()
If m_Socket Is Nothing Then
Try
m_Socket = New Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IP)
m_Socket.Bind(New IPEndPoint(m_IP, 0))
m_Socket.IOControl(SIO_RCVALL, BitConverter.GetBytes(1), Nothing)
m_Socket.BeginReceive(m_Buffer, 0, m_Buffer.Length, SocketFlags.None, New AsyncCallback(AddressOf OnReceive), Nothing)
Catch
m_Socket = Nothing
Throw New SocketException
End Try
End If
End Sub
Private Sub OnReceive(ByVal ar As IAsyncResult)
Try
Dim received As Integer = m_Socket.EndReceive(ar)
Try
If Not m_Socket Is Nothing Then
ReDim m_pkt(received - 1)
Array.Copy(Buffer, 0, m_pkt, 0, received)
OnNewPacket(New Packet(m_pkt))
End If
Catch ex As Exception
'Do Nothing -this is intended
End Try
m_Socket.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, New AsyncCallback(AddressOf OnReceive), Nothing)
Catch
[Stop]()
End Try
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|