Zibit Posted April 10, 2010 Share Posted April 10, 2010 (edited) hi im trying to send data from 1 PC to the other and cant get it right :Sanyway heres the host's Code #include <File.au3> UDPStartup() ;host's IP = 192.168.1.108 ;Client's IP = 192.168.1.150 ; Register the cleanup function. OnAutoItExitRegister("Cleanup") recv() Func recv() $split = 0 Global $socket2 = UDPBind("192.168.1.108", 27020) Do $data = UDPRecv($socket2, "27020") if $data <> 0 then MsgBox(0, "", $data & " - " & $socket2[2]);<---- here's the problem msgbox doesnt show which means packet doesnt arrive if $data <> 0 then $split = StringLeft($data, 1) Until $split = 5 _send() EndFunc ; Open a "SOCKET" ;============================================== Func _send() $socket = UDPOpen($socket2[2], 27021) If @error <> 0 Then Exit $line = _FileCountLines("read.tsf") $nr = Number($line + 1) $n = 0 Do $n = $n + 1 $read = FileReadLine("read.tsf", $n) Sleep(100) $status = UDPSend($socket, $read) Until $n = $line UDPSend($socket, "end") recv() EndFuncAnd heres the Client's script$socket = UDPOpen("192.168.1.108", 27020) $status = UDPSend($socket, "192.168.1.150") UDPCloseSocket($socket) $i = 0 $socket = UDPBind("192.168.1.150", 27021) while 1 $i = $i + 1 $data = UDPRecv($socket, 999999) If $data <> "" Then $datacalc = StringSplit($data, ",") if $datacalc[0] = 2 Then GUICtrlSetData($mylist, $datacalc[2] & "|") if $datacalc[1] = 3 then $i = 0 Do $i = $i + 1 $comp = StringCompare(FileReadLine("settings.ini", $i), $datacalc[2] & "," & $datacalc[1], 0) Until $comp = 0 IniWrite("settings.ini", "Servers", FileReadLine("settings.ini", $i), "") EndIf if $datacalc[0] = 2 Then IniWrite("settings.ini", "Servers", $datacalc[2], $datacalc[1]) if $datacalc[0] = 1 Then ExitLoop EndIf WEndSpent days debugging :S! help!OK just to be clear ! The packet arrives in LAN but it doesnt send from 1 pc to the other :S Edited April 11, 2010 by Zibit Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
jchd Posted April 10, 2010 Share Posted April 10, 2010 UDPRecv takes a (numeric) length as second parameter and "27020" is not a number per se. Might be your problem: requesting to receive zero length, then ... Another question is: why don't you check error conditions after invoking functions that are very likely to fail someday (router reset, cable unplugged, ADSL modem restart, ...)? Is that spending _days_ debugging? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Zibit Posted April 11, 2010 Author Share Posted April 11, 2010 (edited) yh RAM save :S im using a VPS and im going to add a failsafe later... although didnt work "27020" i changed it to 9999999 and nothing :S Edited April 11, 2010 by Zibit Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
trancexx Posted April 11, 2010 Share Posted April 11, 2010 This is the same thing as that other thread on UDP thematic on this page. It's client-server issue. Only one script serves as a server. Not both! I fail to see how something as simple as that can produce so much issues. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Zibit Posted April 12, 2010 Author Share Posted April 12, 2010 i know the host is the server... the client is the connector Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
trancexx Posted April 12, 2010 Share Posted April 12, 2010 For some reason you (and some others obviously) have strange urge to bind on client side. Don't do that. You have socket, don't close it, don't bind. Client doesn't bind. It doesn't work that way. You are probably confused by the description of the UDPRecv() in the help file. Right? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Zibit Posted April 29, 2010 Author Share Posted April 29, 2010 yeah... but bind shows the socket where to recv otherwise it would recv randomly or smth, right ? Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
darkjohn20 Posted April 29, 2010 Share Posted April 29, 2010 STRAIGHT from the help file: Client: ;;This is the UDP Client ;;Start the server first ; Start The UDP Services ;============================================== UDPStartup() ; Register the cleanup function. OnAutoItExitRegister("Cleanup") ; 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 Cleanup() UDPCloseSocket($socket) UDPShutdown() EndFunc Server: ;;This is the UDP Server ;;Start this first ; Start The UDP Services ;============================================== UDPStartup() ; Register the cleanup function. OnAutoItExitRegister("Cleanup") ; 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 Cleanup() UDPCloseSocket($socket) UDPShutdown() EndFunc Experiment with this first. Link to comment Share on other sites More sharing options...
trancexx Posted April 29, 2010 Share Posted April 29, 2010 (edited) yeah... but bind shows the socket where to recv otherwise it would recv randomly or smth, right ?You were told what's causing issues with your scripts. Also I assume you tried script from the other thread with the same thematic made when this thread.And now you're posting that. edit: I was advised to edit. Edited April 30, 2010 by trancexx ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now