Re: vb.net and sockets bug?



Sorry about the double creation. Changing the bind to 1234 does bind PART of
the local port 1234. If I issue a sendto as in my code Sendto(...,1234), the
actual setup of the packet from vb.net shows a send source port of 2011 and
a send dest port of 1234. which is only halfway correct, as verified by
windows network monitor. This is def. a BUG.
I am trying to do something simple. I send to a remote machine(nonwindows)
with a simple UDP packet. I used the code to send 2 bytes of data on port
9001. The remote receives the data but transmits a packet back to me on the
REAL send source port the VB program sent it on which is NOT 9001, it looks
like a windows assigned port. In fact the MSDN says it if you dont assign
the SEND SOURCE PORT for the packet , it will assign a port in the
2000-65535 range. VB is only setting the dest port part of the packet, not
the source send port part of it. I you actually fired the code off and
lookup at it with a sniffer, this happens every time. I am very
frustrated.Since windows is assigning a random port, I cant use the bind to
figure out what port to listen on. Using a sniffer it is easy to see this
bug, using MSDN code or mine, Ive tried several examples from MSDN with same
results.
Any more ideas?
Thanks BUC

"Henning Krause [MVP - Exchange]" <newsgroups_remove@xxxxxxxxxxxxxxxxx>
wrote in message news:u1xM5wTdHHA.3648@xxxxxxxxxxxxxxxxxxxxxxx
Hello,

1. Why are you creating the sockets two times?

2. Add a txSocket.Bind(new IPEndPoint(IPAddress.Any), 1234)

This will bind the socket to the local port 1234, and should solve your
issue.

Best regards,
Henning Krause

"bucrepus" <bucrepus@xxxxxxxxxxxxxxxxxx> wrote in message
news:%23OyWsVTdHHA.2088@xxxxxxxxxxxxxxxxxxxxxxx
Dim UpdateIP As IPAddress
Dim packet(2) As Byte
Dim txSocket As Socket = New Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp)
'load some data of some sort
packet(0) = 1 : packet(0) = 1
UpdateIP = IPAddress.Parse("192.168.0.100")
txSocket = New Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp)
Dim txPLCEP As New IPEndPoint(UpdateIP, 9001)
txSocket.SendTo(packet, txPLCEP)
txSocket.Close()
txSocket = Nothing

'packet is transmitted to 192.168.0.100 with a source dest port of 9001
and a source send port of 2039. Depending on the machine I test this code
on the source send port randomly changes around the 2000 range. verified
with 2 diff packet sniffers including W2k3 server net monitor.

Thanks..
N\BUC




"buc" <bucrepus@xxxxxxxxxxxxxxxxxx> wrote in message
news:uBnKlcKdHHA.2068@xxxxxxxxxxxxxxxxxxxxxxx
Why does VB.NET UDP sockets send data on random ports?. If I set a
simple socket up to transmit a UDP packet on a port, look at the packet
with a sniffer, the actual packets source port and dest.port are diff.
The packets destination port is correct, but the packets source port it
is actually sent from is random. Why? How can I figure out the actual
source port windows is using, not what the vb.net socket is fake
reporting?
Thanks BUC







.



Relevant Pages

  • PATCH: Remove file riowinif.h from rio driver (unused file)
    ... -/* The RUP (Remote Unit Port) structure relates to the Remote Terminal Adapters ... - CONFIG is sent from the driver to configure an already opened port. ... - Packet structure is same as OPEN. ... - of the specified port's RTA address space. ...
    (Linux-Kernel)
  • Re: General questions about Sockets
    ... > could I push it before I see the network slowing down and/or errors? ... Nagle/Delayed ACK interaction but you could confirm it with a packet ... > I can setup any port in my registry, but what would be the 'default' one I ... Google could confirm it. ...
    (microsoft.public.win32.programmer.networks)
  • RE: Strange replies on closed port
    ... port should be a RST - not dropping the packet. ... receiving an UDP datagram to a non 'listening' port. ... that message isn't generated by the end host, ... Connecting to a closed Port w/o Firewall: ...
    (Pen-Test)
  • Re: Please help me interpret a suspicious netstat SYN_SENT TCP port 1058 ?
    ... Your system initiated a connection. ... your computer sends a TCP packet with the SYN ... Process 912 on your system sent a packet from port 1058 ... hoping to connect to the web server running on port 80 ...
    (comp.security.firewalls)
  • Re: Full Plate of Crow
    ... upsurges in port 80 probes and actually ... > firewall is only telling it dropped a packet, not what was in the packet. ... infections based on the data Caida collected. ... > firewall logs, not IDS logs. ...
    (Incidents)