Modify

Opened 10 years ago

Closed 7 years ago

#1869 closed Feature Request (Rejected)

Specify UDP Source Port

Reported by: anonymous Owned by:
Milestone: Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

Discussion here is here, start reading at post 12:
http://www.autoitscript.com/forum/topic/124405-udp-server-talk-to-client/

--

The server's source port in a reply message is random and does not match the servers listen port.

example with current procedures:

  1. server opens on port 251
  2. client sends message to server with destination port 251, source port 1234(random but ok)
  3. server sends reply. destination port 1234, source port 5678(random NOT ok)

How it should be:

  1. server opens on port 251
  2. client sends message to server with destination port 251, source port 1234(random but ok)
  3. server sends reply. destination port 1234, source port 251(not random, same as server port, good!)

To fix this, I suggest UDPOpen() should have an optional parameter to specify source port instead of always using a random port.

As discussed, It is not currently possible to make a UDP DNS server that compiles to RFC specifications. The server should reply to client messages with the servers listen port as it's source port.

;;This is the UDP Server
;;Start this first

#Include <Array.au3>
HotKeySet("{ESC}", "quit")

; Start The UDP Services
;==============================================
UDPStartup()

; Register the cleanup function.
OnAutoItExitRegister("Cleanup")

; Bind to a SOCKET
;==============================================
$Socket = UDPBind("192.168.1.11", 251)

While 1
    ;get UDP data from client
    $Data = UDPRecv($Socket, 50,3)
    
    If IsArray($Data) Then
        ConsoleWrite($Data[0])
        ConsoleWrite(@CRLF)
        
        ;create temp socket from incomming IP/PORT
>>> I should be able to specify a source port with UDPOpen that is the same as the listen port of UDPBind().
        $SocketIn = UDPOpen($Data[1], $Data[2])
        
        ;send a reply message
        ConsoleWrite("Sending reply: Hello Client!")
        $status = UDPSend($SocketIn, "Hello Client!     ") 
        If $status = 0 then
            MsgBox(0, "ERROR", "Error while sending UDP message: " & @error)
            Exit
        EndIf
        
        ;remove temp socket
        UDPCloseSocket($SocketIn)
        $Data[0] = 0
        
        ConsoleWrite(@CRLF)
        ConsoleWrite(@CRLF)
    EndIf
    sleep(100)
WEnd

Func quit()
    UDPCloseSocket($Socket)
    UDPShutdown()
    exit
EndFunc

Matt.

Attachments (0)

Change History (3)

comment:1 Changed 10 years ago by TicketCleanup

  • Version 3.3.6.1 deleted

Automatic ticket cleanup.

comment:2 Changed 8 years ago by Kealper

This could still be quite useful to have, because as it currently sits, AutoIt's UDP stuff leaves much to be desired, and is not very NAT-friendly.

I really do hope things like this end up making their way in to something like v3.3.9.x or so.

comment:3 Changed 7 years ago by Jon

  • Resolution set to Rejected
  • Status changed from new to closed

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The ticket will remain with no owner.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.