Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

solution for 10014 error

Status
Not open for further replies.

krutika

Programmer
Jul 14, 2006
2
US
I'm trying to start a socket in a migrated application (from vb6 to vb.net)
I get 10014 after WSAStartup(257, sWSAData)

the socket structure I have is
Structure sockaddr
Dim sa_family As Short
<VBFixedString(14), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=14)> Public sa_data As String
End Structure

How to solve this error of 'Bad address'?
 
The Best fix i've found for the sockaddr_in structure is

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Size:=16)> _
Public Structure sockaddr_in
<FieldOffset(0)> Public sin_family As System.Int16
Public sin_port As System.UInt16
Public sin_addr As in_addr '
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=8)> Public sin_zero As System.Byte()
'Just padding - could try 2: 4 byte integers(32) or 1: 8 byte integer(64)
End Structure

Where in_addr is

<StructLayout(LayoutKind.Explicit, Size:=4, CharSet:=CharSet.Ansi)> _
Public Structure in_addr
<FieldOffset(0)> Public S_un_b As S_un_b_
<FieldOffset(0)> Public S_un_w As S_un_w_
<FieldOffset(0)> Public S_addr As System.UInt32
End Structure

<StructLayout(LayoutKind.Explicit, Size:=4, CharSet:=CharSet.Ansi)> _
Public Structure S_un_w_
<FieldOffset(0)> Public s_w1 As System.UInt16
<FieldOffset(2)> Public s_w2 As System.UInt16
End Structure

<StructLayout(LayoutKind.Explicit, Size:=4, CharSet:=CharSet.Ansi)> _
Public Structure S_un_b_
<FieldOffset(0)> Public s_b1 As System.Byte
<FieldOffset(1)> Public s_b2 As System.Byte
<FieldOffset(2)> Public s_b3 As System.Byte
<FieldOffset(3)> Public s_b4 As System.Byte
End Structure

works like a charm for the ADDRINFOA structure returned by getaddrinfo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top