Opened 15 years ago
Closed 13 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:
- server opens on port 251
- client sends message to server with destination port 251, source port 1234(random but ok)
- server sends reply. destination port 1234, source port 5678(random NOT ok)
How it should be:
- server opens on port 251
- client sends message to server with destination port 251, source port 1234(random but ok)
- 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 by , 15 years ago
| Version: | 3.3.6.1 |
|---|
comment:2 by , 14 years ago
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 by , 13 years ago
| Resolution: | → Rejected |
|---|---|
| Status: | new → closed |

Automatic ticket cleanup.