Sign in to follow this  
Followers 0
memnon

UDPSend, UDPReceive... ONLY LOCAL ?

4 posts in this topic

Hello,

i tried the both script from the beta helpfile (3.1.1.92): UDPSend, UDPReceive

both scripts are working, if they are started on one and the same machine.

if i try to act as "real" server/client, what means one script on the "serverpc" and one script on the "clientpc" nothing happens.

it has nothing to do with personal firewall, they are disabled on both machines...

here are the two files, copied from the helpfile:

;;This is the UDP Server

;;Start this first

; Start The UDP Services

;==============================================

UDPStartup()

; Bind to a SOCKET

;==============================================

$socket = UDPBind("127.0.0.1", 65532)

If @error <> 0 Then Exit

While 1

$data = UDPRecv($socket, 50)

If $data <> "" Then

MsgBox(0, "UDP DATA", $data, 1)

EndIf

sleep(100)

WEnd

Func OnAutoItExit()

UDPCloseSocket($socket)

UDPShutdown()

EndFunc

;;This is the UDP Client

;;Start the server first

; Start The UDP Services

;==============================================

UDPStartup()

; Open a "SOCKET"

;==============================================

$socket = UDPOpen("127.0.0.1", 65532)

If @error <> 0 Then Exit

$n=0

While 1

Sleep(2000)

$n = $n + 1

$status = UDPSend($socket, "Message #" & $n)

If $status = 0 then

MsgBox(0, "ERROR", "Error while sending UDP message: " & @error)

Exit

EndIf

WEnd

Func OnAutoItExit()

UDPCloseSocket($socket)

UDPShutdown()

EndFunc


das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Change UDPBind("127.0.0.1", $Port) to UDPBind(@IpAddress1, $Port)

You are trying to project a server on your computer towards your own computer, using ipaddress1 it projects is towards the web. You cannot use a string at all because it cannot process the string into a number to properly projet. Change it to @IpAddress1 and it will work fine. Make sure your client is set to your ipaddress to connect to it. You can also check out other scripts such as my TCP Made Easy funcs, Server Communicator, and ITS Chat project.

I am glad I could help.

AutoIt Smith

P.S. Files located in Fileman

Edited by AutoIt Smith

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Change UDPBind("127.0.0.1", $Port) to UDPBind(@IpAddress1, $Port)

You are trying to project a server on your computer towards your own computer, using ipaddress1 it projects is towards the web. You cannot use a string at all because it cannot process the string into a number to properly projet. Change it to @IpAddress1 and it will work fine. Make sure your client is set to your ipaddress to connect to it. You can also check out other scripts such as my TCP Made Easy funcs, Server Communicator, and ITS Chat project.

I am glad I could help.

AutoIt Smith

P.S. Files located in Fileman

thx for your quick response, it seems to work with the both files, now i can try to get my syslog to work...

i have a firewall and i want to get the messages over syslogs. syslog means UDP 514, what i dont know is the lenght of the packet i should receive then....

YES, it works NOW :P

thank you very much

Edited by memnon

das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

is it possible to send data from the Server -> Client

thought a connection which is established from the Client -> Server?

the Problem is

the Client is behind Firewall/Router

the Server is fully accessable

this is my Code:

Client:

;;This is the UDP Client
;;Start the server first

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

; Open a "SOCKET"
;==============================================
$socket = UDPOpen("127.0.0.1", 65532)
If @error <> 0 Then Exit

While 1
$data = UDPRecv($socket, 50)
If $data <> "" Then
MsgBox(0, "UDP DATA", $data, 1)
EndIf
sleep(100)
WEnd

Func OnAutoItExit()
UDPCloseSocket($socket)
UDPShutdown()
EndFunc

Server:

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

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

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

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

Func OnAutoItExit()
UDPCloseSocket($socket)
UDPShutdown()
EndFunc

but it seems like it not even works localy....

can someone help me to solve this problem?

If i use TCP instead of UDP it works fine...

Edited by dennor

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  
Followers 0