Jump to content

Receiving data from server via TCP


Recommended Posts

Hello,

I've been trying to use this API https://vndb.org/d11 however due it using the TCP connection I'm having issues getting any response back as I've never dealt with TCP.

#include <MsgBoxConstants.au3>

Local $Port = 19534
Local $Server = '51.15.19.21'

TCPStartup()
OnAutoItExitRegister("OnAutoItExit")
Global $Socket = TCPConnect($Server, $Port)
If $Socket = -1 Then Exit MsgBox(16, 'Error', 'Connection error.')
TCPSend($Socket, 'login {"protocol":1,"client":"test","clientver":"0.1"}0x04')
;TCPSend($Socket, 'dbstats0x04')

While 1
    $Data = TCPRecv($Socket, 512)
    If $Data <> '' Then
        MsgBox(0, 'Received:', $Data)
        TCPCloseSocket($Socket)
    EndIf
Sleep(50)
WEnd

Func OnAutoItExit()
    TCPShutdown()
EndFunc

I'm fairly certain there's nothing wrong with the code, I've looked up multiple examples on the forums from other users and no matter how I try and send the data I simply am not getting any response.

Perhaps I'm missing something from the documentation of the API itself but I can't quite figure out what.

Link to post
Share on other sites
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...