1 post in this topic
this is the first time to post a problem with autoit, I have been using it for more than 3 years but im still feel new
I have a VPS running online game ,
I'm making an program witch reads packets from server/client, first of all it reads size of the packet(it may be 1-5 bytes in size), and then reads what's left.
Problem: TCPRecv($socket,1,1) tooks really long to receive 1 byte, most of the time 100ms!
You can see packets here and how much time it took to read size of them(1-5 bytes, all of them are 1 byte in size): 0xAA63 (99.8802703210873ms) 0x53 (99.8829718030123ms) 0x2B (99.7435753356861ms) 0x4E (100.176352740059ms) I want to interrupt sometimes server or client, send packets, but I cannot send packets if server/client didn't get last packet. Sometimes packets are huge(16MB or even more), sometimes they are 2-6 bytes in size. I just don't want to receive everything and just send it. I want to see every packet, and collect data from these packets.
EDIT: I receive couple packets at the same time with TCPRecv to make it faster. I use TCPRecv($socket,10000,1). It made program a bit faster... But still, when receiving again these packets, it still tooks 100ms. It's still slow.
How to make TCPRecv($socket,1,1) faster? I don't need any error checking or etc., just to make it as fast as possible. (I only receive everything in hexadecimal)
I really need help with this... It's so slow and annoying!
This script is based on algorithm code from EnrMa.
Updated: January 07, 2017
Changes are in the script header.
POST is not working consistently in uploading files. AutoIt x64 does not work properly with this script.
I've a problem with receiving data on my PC by TCP and UDP. I can send data to another computer, but can't receive it.
I'm not shure where is the problem (on PC or on "another comupers")
This is client code:
;TCP client TCPStartup() $socket = TCPConnect("192.168.0.18", 7777) ;try to connect to server and save number of socket If $socket = -1 Then ;if $socket = -1 then error MsgBox(16, "Error:", "Can't connect to server") EndIf $sendedBytes = TCPSend($socket, "nothing here :)") ;send message to connected socket If $sendedBytes = 0 Then ;if receiving data TCPSend(...) = 0 then error MsgBox(16, "Error", "Can't send message") EndIf TCPCloseSocket($socket) TCPShutdown() and server code:
;TCP server TCPStartup() $mainsocket = TCPListen("192.168.0.18", 7777) ;making main receiving socket While 1 ;receiving loop $acceptedSocket = TCPAccept($mainsocket) ;possible connection to accept If $acceptedSocket <> -1 Then $receivedData = TCPRecv($acceptedSocket, 1024) ;if main socket is connected then receive message MsgBox(64, "Received message!", "Message: " & $receivedData) TCPCloseSocket($acceptedSocket) ;close open connecion EndIf WEnd TCPShutdown()
When server is on PC I can't receive any messages from any other computers.
When client is on PC I can receive messages on any another computer.
I tried to turn off antiviruses and windows firewall but it did't change anything
Error code from client from TCPConnect is 10060 (connection time out) and from TCPSend: 10038
I've found something about 10060 error code, Microsoft says "Connection timed out. A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond."
So it means that the problem is with time of response but it makes no sense couse "another computer" is Virtual Machine with bridge internet connection from PC (pings beetwen PC and VM are lower than 1ms.
About 10038 error code microsoft says that this is problem with socket and it actually makes sense.
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 *