This is a discussion on Re: 10047 Address Family is not Supported - Programmer ; "Gisle Vanem" wrote in message news: ... > "Colin Pimlott" wrote: > > > I get the error code 10047 (Address Family is not supported) when > > attempting a network broadcast. > > > > The relevant VB6 code ...
wrote in message news:<firstname.lastname@example.org>...
> "Colin Pimlott"
> > I get the error code 10047 (Address Family is not supported) when
> > attempting a network broadcast.
> > The relevant VB6 code is
> > Winsock1.Protocol = sckUDPProtocol
> > Winsock1.LocalPort = 0
> > Winsock1.RemotePort = 1000
> > Winsock1.RemoteHost = "255.255.255.255"
> > Winsock1.Bind
> You must enable broadcast by
> BOOL on = TRUE;
> setsockopt (sock, SOL_SOCKET, SO_BROADCAST, (const char*)&on, sizeof(on));
I am using the MSWinsck.ocx control, and I have tried to do this with
Const SO_BROADCAST = &H20
Const SOL_SOCKET = &HFFFF
Public Type OptType
Opt As Long
Public Declare Function setsockopt Lib "wsock32.dll" (ByVal sock As
ByVal level As Integer, ByVal optname As Integer, _
optval As OptType, ByVal optlen As Integer) As Integer
optval.Opt = 1
intErr = setsockopt(Winsock1.SocketHandle, SOL_SOCKET, SO_BROADCAST,
...but it always returns -1 (SOCKET_ERROR). I presume I should call
setsockopt after the Winsock1.Bind function call.
I don't know if the socket handle returned by the ocx is the same as
the one it passes to the winsock layer.