I feel like I am getting close but nothing useful is happening and I
have an error message and code when I look at the variables. Here's the
send routine:
------------------------------------------------------
(way up top, among others)
Imports System.Net.Sockets
(in the project module)
Friend Const InverterPort As Integer = 14917
(in the form)
dim rc as integer
Dim s As New Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp)
Dim broadcast As IPAddress = IPAddress.Parse("10.0.0.101") '
replace with pccbackup.no-ip.info for remote testing/operation 24x7.
Dim endpoint As New IPEndPoint(broadcast, InverterPort)
Dim iUniqueBox As Integer = 1119
Dim sendbuf As Byte() = BitConverter.GetBytes(iUniqueBox)
rc = s.SendTo(sendbuf, endpoint)
------------------------------------------------------
When it runs, rc gets set to 4. I see no documentation of what this
means. Maybe that is the number of bytes sent??? They loosely refer to
knowing how many bytes are sent but never reference or code this int
value in the examples I have found.
When I breakpoint on s.SendTo and hover on the "endpoint" variable, it
gives a box with "Address" as the name of the first item in the list.
When I hover on "broadcast" in that info box, it gives a box with an
error code 10045 and a message saying that "The attempted operation is
not supported for the type of object referenced." I don't get this
displayed to me, but see it there.
It seems to want to send the correct four bytes out but nothing happens.
I never get an answer. I don't think anything is going out. I have
only replaced the previous ActiveX send statement with this routine. The
receive routine is untouched and working so far. Just doing a little at
a time.
By changing "10.0.0.101" to "pccbackup.no-ip.info" anyone can try this
remotely at any time of the day or night and see what I mean. It should
return 38 integers.
As usual, many thanks for any pointers. This little deal is making me
crazy and has been for six months! I think this is as simple as I can
make it and still not getting the job done.
Still lost Mike
P.S. Here's the Java send/receive routine this is based on:
//Step 3) Send the 4 byte request packet to port 14917
InetAddress address = InetAddress.getByName(args[0]);
DatagramPacket packet = new DatagramPacket(buffer, 4, address, 14917);
socket.send(packet);
System.out.println( "" );
System.out.println( "Sending Packet to: "+ args[0] );
//Step 4) Get the response packet from the PVM1010
packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
System.out.println( "" );
System.out.println( "Response Packet size: "+ packet.getLength() );
System.out.println( "" );
-----------------------------------------------------------
I'm not sure. Have you tried System.Net.Sockets.UdpClient? My example
dealed
only with IP which, as you probably know, is one layer below UDP and not
an
alternative.
Have a look here:
http://msdn.microsoft.com/en-us/library/c19ex43h.aspx
and
UDP sub topic
http://msdn.microsoft.com/en-us/library/tst0kwb1.aspx
Armin