I am using standart UDP function of AutoIt. I tested and dumped UDP packets to loopback interface 127.0.0.1 (send udp packets to myself). I captured it with RawCap, then opened in Wireshark. It showed me that there is a problem with Header Check sum. Why? Can I somehow encapsulate HTTP inside UDP (using AutoIt)?
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
HotKeySet("{esc}", "Cleanup")
HotKeySet("{enter}", "sendData")
Global $ConnectedSocket = -1
Global $MainSocket
Local $g_IP, $RogueSocket, $GOOEY, $edit, $input, $butt, $msg
Local $ret, $recv
$g_IP = "127.0.0.1"
$_INCOMING_FLAG = "UDP DATA: "
OnAutoItExitRegister ("Cleanup")
; 1. UDP Listener ### Start The UDP Services ###
;==============================================
UDPStartup()
OnAutoItExitRegister ("Cleanup")
; 1. UDP Listener ### Create a Listening "SOCKET"
;==============================================
$socket = UDPBind($g_IP, 65432)
If @error <> 0 Then Exit
; 3. GUI ### Create a GUI for chatting
;==============================================
$GOOEY = GUICreate("P2P Chat", 300, 200)
$edit = GUICtrlCreateEdit("", 10, 40, 280, 150, $WS_DISABLED)
$input = GUICtrlCreateInput("", 10, 10, 200, 20)
$butt = GUICtrlCreateButton("Send", 210, 10, 80, 20, $BS_DEFPUSHBUTTON)
GUISetState()
; GUI Message Loop
;==============================================
While 1
$msg = GUIGetMsg()
If $msg = $GUI_EVENT_CLOSE Then ExitLoop
If $msg = $butt Then sendData()
$data = UDPRecv($socket, 200)
If $data <> "" Then
GUICtrlSetData($edit, GUICtrlRead($edit) & $_INCOMING_FLAG &$data & @CRLF)
EndIf
;~ Sleep(50)
WEnd
GUIDelete($GOOEY)
Func sendData()
If $socket <> 0 Then
$status = UDPSend($socket, GUICtrlRead($input))
If $status = 0 Then
MsgBox(0, "ERROR", "Error while sending UDP message: " & @error)
Exit
EndIf
ElseIf $ret > 0 Then
; UPDATE EDIT CONTROL WITH DATA WE SENT
;----------------------------------------------------------------
GUICtrlSetData($edit, GUICtrlRead($edit) & GUICtrlRead($input) & @CRLF)
GUICtrlSetData($input, "")
EndIf
EndFunc ;==>sendData
Func Lookup()
; If no connection look for one
Return 0
EndFunc ;==>Lookup
Func Cleanup()
UDPCloseSocket($socket)
UDPShutdown()
EndFunc ;==>Cleanup
I'm guessing all of the errant checksums are 0x0000
; in that case, you are probably running into TCP Checksum Offloading . This is the operating system trying to let the networking hardware calculate the checksum (which will reduce load on the CPU). These checksums are not an error in your application.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.