I have configured a vb6.0 app with a winsock control configured
haphazardly. I say haphazardly because there are no winsock udp
multicast examples in any Microsoft documentation or any where else
for that matter.
I can send messages to the Unix machine, it receives them and parses
them perfectly. Messages coming back are not received by the vb6.0
app.
Question 1. Can the winsock control be configured udp multicast?
Since all the examples show unicast.
Question 2. Does anyone have sample code if it is possible? is there
any other way that I can receive this udp multicast traffic in a vb6.0
application.
Thanks
emp1953
Can you show the code you use to configure the winsock control, and
any static setup of the properties? I use winsock with UDP for
broadcast in a mixed Windows / Irix environment. As far as I know, you
should be able to do this using broadcast to a multicast IP range
(assuming you're on the same network segment).
What does netstat -nr show for the multicast range? (224.xxx etc). IOW
are you sure there's a route from multicast to your host, on the
Windows side?
Also, depending on the age of the OS and the stack, you may need to
call setsockopt() to allow broadcast over UDP. Anything newer than
Win2K SP1 should be OK.
--
Jim
Jim, Keep in mind that the UNIX box is broadcasting multicast and
other LINUX and UNIX machines on the LAN are reading it fine.
Oh, it is a closed local network, 4 machines running through an
ethernet switch, my PC will make it 5. Where is the setsocketopt()
call? on the UNIX side? That seems to work fine already with the non-
windows machines.
Here's the code - not much to it:
udpRemoteHost = "224.0.10.101"
udpRemotePort = 6301
Me.udpServer.Bind 6300
Me.udpServer.RemoteHost = udpRemoteHost
Me.udpServer.RemotePort = 6301
I did the netstat -nr on the PC. what am I looking for. I couldn't
copy and past the results here. I took a .bmp of it but can't post
that here either.
I could email it to you.
Thanks, Ed
On the Windows PC. Like this:
' Options for socket level
'
Private Const SOL_SOCKET As Long = 65535
' Permit sending of broadcasts
'
Private Const SO_BROADCAST As Long = &H20&
Private Declare Function setsockopt Lib "wsock32.dll" _
(ByVal hSocket As Long, _
ByVal Level As Long, _
ByVal optname As Long, _
optval As Any, _
ByVal optlen As Long) As Long
---------
' in a function "InitSocket(ByVal Port As Long)"
With wskMain
.Protocol = sckUDPProtocol
.Bind Port, .LocalIP
Res = setsockopt(.SocketHandle, _
SOL_SOCKET, _
SO_BROADCAST, 1&, 4&)
If Res <> SOCKET_ERROR Then
.RemoteHost = "255.255.255.255"
End If
End With
That's my whole setup for using UDP for pure broadcast -- substitute
your multicast address for the .RemoteHost address.
> I did the netstat -nr on the PC. what am I looking for. I couldn't
> copy and past the results here. I took a .bmp of it but can't post
> that here either.
> I could email it to you.
You could always do "netstat -nr >stat.txt" to redirect the output to
a text file. But all I'm asking is, if there's a line in the output
like the following:
Destination Netmask Gateway Interface Metric
224.0.0.0 224.0.0.0 192.168.1.198 192.168.1.198 1
This tells you that multicast traffic can reach your local ethernet
adapter.
--
Jim
What Jim said, but don't specify the IP address in Bind call. It's optional,
but Winsock control documentation for the control doesn't say "optional". I
am not sure how the Winsock control calls the underlying bind() function,
but when you omit the IP, your software is supposed to listen or accept
connections from all adapters.
The netstat -nr command gives me 224.0.0.0 224.0.0.0 then my pc's IP
address in the next two columns.
I'll try your socket configuration and see what happens.
I would have thought this would have been more straight forward. UDP
multicast is not an unheard of application. In fact it is quite
common in a lot of areas.
Here's the netstat -nr output
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x1000003 ...00 06 5b be 1b db ...... 3Com EtherLink PCI
0x1000004 ...00 07 e9 0a 9e bc ...... Intel(R) PRO/1000 Adapter
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface
Metric
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1
1
129.134.0.0 255.255.0.0 129.134.197.201 129.134.197.201
1
129.134.197.201 255.255.255.255 127.0.0.1 127.0.0.1
1
129.134.255.255 255.255.255.255 129.134.197.201 129.134.197.201
1
224.0.0.0 224.0.0.0 129.134.197.201 129.134.197.201
1
255.255.255.255 255.255.255.255 129.134.197.201 129.134.197.201
1
===========================================================================
Persistent Routes:
None
That does show a route from multicast to your adapter, so no problem
there.
Does your PC really have a public address on a Class B net? Is that
also true of the *nix boxes you want to participate with? In any case,
you seem to have two adapters but only one has an IP address. Do you
use both adapters?
Re: your comment about it being more straightforward... except for the
added setsockopt, which should only be needed in the case of older
versions of Windows, what about this strikes you as complicated?
The next step might be a packet sniffer like Ethereal, filtering out
all traffic except multicast. I'm not sure how much that will tell
you, though, since you say that it all works except for receiving on
the Windows machine. Wouldn't happen to have a Network General box
sitting unused, eh? (-:
--
Jim
The O.S. is W2k with sp3.
What strikes me as being complicated? I've been making computers and
test equipment talk to each other for quite a while.
I could get it all done. This time around has me stumped and I don't
get that way too often. I've seen a number of questions about
implementing winsock UDP multicast on various on-line groups with no
answers, questions from back as far as 2001.
Only one of the ethernet ports is being used and I am plugged into the
correct one because I can send to the UNIX box. I'll activate
Wireshark on the PC and take a see if it offers any clues. The
machine is set up to be on the net as well but right now it is running
stand alone. The IP address is valid. It was assigned by my IT dept.
From my O.S. rev level it looks like I won't need the setsocketopt( )
call, right. I might just throw it in there to see what it does.
No Network General equipment at all, sorry.
Jim,
Running Wireshark(I think that this product used to be called
ethereal) on the PC shows the multicast traffic from the multicast
address on the UNIX box.
The "Res" returned on the setsockopt function call in your method is a
zero.
SOCKET_ERROR = empty so I changed the if statement to if <> 0
If I don't do this, no remotehost address is set thus I get a run time
error "address family not supported"
Additionally, I do get a socket handle back.
Sorry, SOCKET_ERROR is -1. Your substitution is OK
It looks like there's more to this than there is for broadcast. You
will have to explicitly (using setsockopt again) join the multicast in
order to receive anything.
This is beyond the scope of this forum and my direct experience. You
can find information on MSDN, but none of it is related to VB, so
you'd have to put on your C++ hat and start translating.
Look for "Receiving an IP Multicast Datagram" in/on MSDN.
--
Jim