40 posts in this topic
Hi, when a client sends /logout to the server i want that the server find the id of the client and set his online status to 0
Using 'default' I have no problems, but when I do this with 'blank517' gives me id 10 and then for the database remains online
Database while Blank517 logout:
id | username | password | permissions | online |
0 | default | pass1 | 0 | 0 |
1 | Blank517 | pass | 0 | 1 |
Func _Recv_From_Sockets_() For $0 = 1 To $max_connections $Recv = TCPRecv ($Socket_Data[$0],1024) If StringLeft($Recv, 1) = "/" Then If StringInStr($Recv, "logout") Then _SQLite_Query(-1, "SELECT id FROM Users WHERE username = '" & $Socket_Data[$0] & "' AND online = '1';", $hQuery) While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK $sMsg &= $aRow; <-- $sMsg = 10 after FetchData WEnd _SQLite_Exec(-1, "UPDATE Users SET online = '0' WHERE id = '" & $sMsg & "';") For $000 = 1 To $max_connections TCPSend($Socket_Data[$000], $Socket_Data[$0] & " ha effettuato il logout") Next TCPCloseSocket($Socket_Data[$0]) $sMsg = Null EndIf Else _Broadcast_To_Sockets_ ($Recv) EndIf Next EndFunc *excuse me for my bad english *
Send message using TCP in autoIT is not work
Hello every body! I am trying to dev an simple chat using TCP. but it don't work for me. Please help me.
I want to in 1 second, Client will send to server a message. And then, Server recv this message and write to Console. But when i run server and client. In server, i was recv only one message. Please tell me why?
In server, i code:
#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $r = @CRLF; Global $ip = "127.0.0.1" Global $port = 1337 Global $client, $iSocket TCPStartup() $iSocket = TCPListen($ip, $port) While 1 $client = TCPAccept($iSocket) If $client <> -1 Then TCPSend($client, "Client is Connected"); EndIf $msg = TCPRecv($client, 1024) if StringLen($msg) <>0 Then ConsoleWrite("Server recv: " &$msg) EndIf TCPSend($client, "Send this msg to client"); Sleep(1000) WEnd In client, i code:
#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $ip = "127.0.0.1" Global $port = 1337 Global $r = @CRLF; TCPStartup() $server = TCPConnect($ip, $port) While 1 TCPSend($server, "Send msg to server") Sleep(1000) WEnd
Autoit real time server with INet
please help me,
my script not working, i want gui run like local real time
#NoTrayIcon #include <INet.au3> #include <String.au3> #include <array.au3> Local $Refresh = 0 ; Set refresh OFF Local $Timer = TimerInit() Local $RefreshEvery = 1 ; seconds ;Global $nCheck Global $link = BinaryToString (InetRead ("http://test.no-ip.info/time.asp")) Global $timeserver = _StringBetween($link, 'id="timeserver">' , '</span>') Global $realtime = $timeserver GuiCreate("Time My Server",200,50) $htime = GuiCtrlCreateLabel("", 10, 10, 180, 20) $btnStart = GUICtrlCreateButton("Start", 40, 30, 57, 17) $btnStop = GUICtrlCreateButton("Stop", 110, 30, 57, 17) GuiSetState() While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $btnStart $Refresh = 1 ; Set refresh ON Case $nMsg = $btnStop $Refresh = 0 ; Set refresh OFF EndSelect If $Refresh And (TimerDiff($Timer) > $RefreshEvery*1000) Then time() $Timer = TimerInit() EndIf WEnd Func time() ;If @SEC <> $nCheck Then GUICtrlSetData($htime, "The current time is " & $realtime) ;$nCheck = @SEC ;EndIf EndFunc
Parsing binary data frames from an asynchronous source
I was just working on a project that involved decoding a stream of binary data from a serial port in AutoIt. It took me a few hours to figure out how to process the data efficiently in AutoIt and I did not find any helpful examples on how to do so, so I thought I would share my core example and maybe save someone else some time. There may be a more efficient way to do this, but this works well for me.
#cs Author: ToasterKing This is an example of a way to parse streaming binary data that follows a strict format with a header and footer. In this example, each frame is 5 bytes with a 2-byte header of 0xD5AA and a 1-byte footer of 0xAD. The _BinaryParse() function accumulates incoming data in a buffer. Once a footer is found, it searches backward for the header, and if it is in the right position, it extracts the remaining 2 bytes in the middle, then moves on to looking for the next frame. #ce ; The data source might be something asynchronous like serial or TCP, but since this is just an example, I'm just putting the data in a variable. Local $fSomeData $fSomeData = Binary("0xD5AA24B1") ; Binary data constituting almost a complete frame. _BinaryParse($fSomeData) ; Call the function with the received data. It isn't a complete frame, so it is just stored in the buffer until more data is received. $fSomeData = Binary("0xAD62D5AA92E7AD") ; Remainder of the previous frame, one garbage byte (0x62) which should be skipped, and a complete additional frame. _BinaryParse($fSomeData) ; The function should be able to parse both frames now. Func _BinaryParse($fNewData) Local Static $fBinaryReceived = Binary("") ; Buffer for received data ConsoleWrite("Hey, the function is called!" & @CRLF) ; Add new data to the buffer. ; This ridiculous monstrosity is the only way I could find to append binary data to binary data in AutoIt. It must be converted to strings first. ; Both, one, or no substrings will begin with "0x" depending on whether they contained binary data. To be converted back to binary properly, only one instance ; of "0x" must exist at the beginning of the string. $fBinaryReceived = Binary("0x" & StringReplace(String($fBinaryReceived) & String($fNewData),"0x","")) ConsoleWrite("Data in the buffer: " & String($fBinaryReceived) & @CRLF) Local $iLength = BinaryLen($fBinaryReceived) ; Count the bytes in the data If $iLength > 0 Then Local $fBinaryReceivedTemp = $fBinaryReceived ; Create temporary copy to work on Local $fByte1,$fByte2 For $i = 1 To $iLength If BinaryMid($fBinaryReceivedTemp,$i,1) = 0xAD Then ; If the 1-byte footer found ConsoleWrite("Footer found at end of " & $i & " of " & $iLength & " bytes!" & @CRLF) If BinaryMid($fBinaryReceivedTemp,$i - 4,1) = 0xD5 And BinaryMid($fBinaryReceivedTemp,$i - 3,1) = 0xAA Then ; and the 2-byte header is found 4 bytes before that ConsoleWrite("Header found before the footer!" & @CRLF) $fByte1 = BinaryMid($fBinaryReceivedTemp,$i - 2,1) ; Get 1st byte in the body (between header and footer) $fByte2 = BinaryMid($fBinaryReceivedTemp,$i - 1,1) ; Get 2nd byte in the body (between header and footer) ConsoleWrite("Here is the critical data: " & String($fByte1) & " " & String($fByte2) & @CRLF) ; Just display the 2 bytes for demonstration purposes. Normally, you'd do something more useful with it here. EndIf $fBinaryReceived = BinaryMid($fBinaryReceivedTemp,$i + 1) ; Truncate the original data to remove all of the bytes just processed, then continue processing $fBinaryReceivedTemp EndIf Next EndIf EndFunc
Hi I have an idea of creating a parental filter (freeware) , which will be protecting children from navigating to adult websites. I want to ask, what is your opinion, how to do it best way?
How to catch the traffic from the very beginning?
For example if a user is starting IE or Firefox, or if he has some alternate BLABLA-browser - how can I catch the url before actual navigation to website, so that my script could first check if the website is ok, and then if it decides that the website is not ok, just block connection to this IP.
Looking forward to your opinions, Great thanx in advance!