Jump to content

how to talk from udp server to udp client.


yucatan
 Share

Recommended Posts

Hello

i'm building an udp server with an udp client but i seems i cant get it working to send a message from the udp server to the udp client

Anyone any help?

client:

UDPStartup()
;188.165.40.108:29022
$socket = udpopen("127.0.0.1", 65532)
If @error <> 0 Then
    ConsoleWrite(@error)
    Exit
EndIf



;$cdkey = $argv[3]
;$cdkeypart = substr($cdkey, 0, 16)
;$pbguid = "123456789abcdef1234567890abcdefa"


;ÿÿÿÿgetKeyAuthorize 0 XHU6E7666HHJPAP3 PB 123456789abcdef1234567890abcdefa     WL3ZW7QJXJA3P3GE8DE3
$data = ""
$auth =   udpsend($master, "ÿÿÿÿgetKeyAuthorize 0 P7XLP5EH6A5HJL7L PB 123456789abcdef1234567890abcdefa")
$status = udpSend($socket, 'ÿÿÿÿgetchallenge 0')
While 1
$data = udpRecv($socket, 99999)
if $data <> "" Then
           ConsoleWrite($data & @CRLF)
        exitloop
   EndIf
WEnd

$challange = StringMid($data, 22, 20)
ConsoleWrite($challange&@LF)


$challange = StringReplace($challange, " ", "")
ConsoleWrite($challange&@lf)

UDPSend($socket, "ÿÿÿÿconnect \cg_predictItems\1\cl_anonymous\0\cl_punkbuster\1\cl_voice\1\cl_wwwDownload\1\rate\25000\snaps\20\name\yorickispro\protocol\118\challenge\"&$challange&"\qport\30336")
;ÿÿÿÿconnect "\cg_predictItems\1\cl_anonymous\0\cl_punkbuster\1\cl_voice\1\cl_wwwDownload\1\rate\25000\snaps\20\name\FMNZRIMY\protocol\118\challenge\-1350344700\qport\30336"

While 1
$data = udpRecv($socket, 99999)
if $data <> "" Then
           ConsoleWrite($data & @CRLF)
        ;exitloop
   EndIf
WEnd


;ConsoleWrite($teller & @CRLF)
;until $henk=0

server:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <Array.au3>
UDPStartup()
OnAutoItExitRegister("Cleanup")

; Bind to a SOCKET
;==============================================
Local $socket = UDPBind("127.0.0.1", 65532)
If @error <> 0 Then Exit

Local $file, $btn, $msg, $myedit, $msg


       GUICreate("My GUI edit",700,700) ; will create a dialog box that when displayed is centered
$file = GUICtrlCreateInput("", 10, 650, 300, 20)
$myedit = GUICtrlCreateEdit("" & @CRLF, 0, 0, 600, 600, $ES_AUTOVSCROLL + $WS_VSCROLL)
$handle = GUICtrlGetHandle ( $myedit )


GUICtrlSetData($myedit, "UDP server started"&@crlf,"1")
    GUISetState()
    ; Run the GUI until the dialog is closed
    While 1
        $data = ""
        $msg = GUIGetMsg()
         If $msg = $GUI_EVENT_CLOSE Then ExitLoop
        Local $data = UDPRecv($socket, 99999)
            If $data <> "" Then UDPSend($socket[1], "ÿÿÿÿchallengeResponse 1425526264")

            GUICtrlSetData($myedit, $data &@crlf,"1")





WEnd
        GUIDelete()
        exit









While 1

WEnd
sleep (100)



$data = ""
While 1

    Local $data = UDPRecv($socket, 99999)
    If $data <> "" Then
        ConsoleWrite($data & @LF)
    EndIf
    Sleep(100)
WEnd




Func Cleanup()
    UDPCloseSocket($socket)
    UDPShutdown()
EndFunc   ;==>Cleanup
Link to comment
Share on other sites

Have a look at the example code in UDPRecv and UDPSend. Combine both and you have an UDP client/server application.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

If you send data from A to B then A is the client and B the server. If you then want to send some data back from B to A then A needs to be the server.

Which means you need to run client and server on A and B.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Water is this only with autoit applications or is this just the UDP protocol?

because for example call of duty uses udp to communicate between client een server but ofcrouse people that play call of duty dont have port forwarding.

but still a call of duty server is able to send data towards call of duty players. and i'm sure this is done by udp

do you maby have an explaination for that?

Link to comment
Share on other sites

Looks like your already has both functions implemented (send and receive).

If it is not working you need to add some debugging code (MsgBox etc.).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I don't understand. A socket address is the IP address plus port number. So this aren't two different things.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Looks like the IP used for sending the data is wrong.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

If a message you send from the server to the client  is being read from the server then you either

  • send the message to the wrong ip:port
  • ip:port is correct but the message is forwarded by the client to the sender

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...