Jump to content
Sign in to follow this  
Zibit

[HELP] UDP Send and recive

Recommended Posts

Zibit

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

_Main()
UDPStartup()
Func _Main()
    Local $filemenu, $fileitem, $recentfilesmenu, $separator1
    Local $exititem, $helpmenu, $aboutitem, $okbutton, $cancelbutton
    Local $msg, $file
    local $username, $password, $socket, $n, $status
    #forceref $separator1

    GUICreate("Kal-Black Register Script", 300, 200)
        $status = UDPSend($socket, "Message works!", $username, $password & $n,); this line is wrong i think
    $n=0
    $socket = UDPOpen("127.0.0.1", 80)
    $filemenu = GUICtrlCreateMenu("File")
    $fileitem = GUICtrlCreateMenuItem("Open...", $filemenu)
    $recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu)
    $separator1 = GUICtrlCreateMenuItem("", $filemenu)
    $exititem = GUICtrlCreateMenuItem("Exit", $filemenu)
    $helpmenu = GUICtrlCreateMenu("?")
    $aboutitem = GUICtrlCreateMenuItem("About", $helpmenu)
    $okbutton = GUICtrlCreateButton("OK", 50, 130, 70, 20)
    $cancelbutton = GUICtrlCreateButton("Cancel", 180, 130, 70, 20)
    $username = GuiCtrlCreateInput("", 10, 15, 130, 20)
    $password = GuiCtrlCreateInput("", 10, 45, 130, 20)
    GuiCtrlCreateLabel("Username", 150, 15, 150, 130)
    GuiCtrlSetColor(-1,0xff0000)
    GuiCtrlCreateLabel("Password", 150, 45, 150, 130)
    GuiCtrlSetColor(-1,0xff0000)
    GUISetState()

    While 1
        $msg = GUIGetMsg()


        Select
            Case $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton
                ExitLoop

            Case $msg = $fileitem
                $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)")
                If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu)

            Case $msg = $exititem
                ExitLoop

            Case $msg = $okbutton
                MsgBox(0, "Click", "You clicked OK!")

If @error <> 0 Then Exit


    While 1
    Sleep(2000)
    $n = $n + 1
    If $status = 0 then 
        MsgBox(0, "ERROR", "Error while sending UDP message: " & @error)
        Exit
    EndIf
    WEnd

    UDPCloseSocket($socket)
    UDPShutdown()

            Case $msg = $aboutitem
                MsgBox(0, "About", "Kal-Black Register File")
        EndSelect
    WEnd

    GUIDelete()

    Exit
EndFunc;==>_Main

can anyone tell me whats wrong with this script ???

i get error

somethink is wrong with var $status can you check it out i cant get the problem ..

Edited by Zibit

Share this post


Link to post
Share on other sites
Jos

no i dont think so still getting errors failed sending...

The sequence of events have to be:

UDPStartup()

UDPOpen()

UDPSend()

... and you are sure this is happening in your script?

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  

×