• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

OTClient TCP/IP communication

MagicWall

Veteran OT User
Joined
Oct 12, 2008
Messages
124
Solutions
6
Reaction score
344
Hi,
I have problem with TCP/IP communication betwen two otclients.

In first OTClient I create server:
otclient/server.cpp at master · edubart/otclient · GitHub
Lua:
local Serv = nil

function testCreateServer()
    Serv = Server.create(7175)
end

In second OTClient I connect to the server and send something using protocol:
otclient/protocol.cpp at master · edubart/otclient · GitHub
Lua:
local Send = Protocol.create()

function testConnectSend()
    Send:connect("127.0.0.1", 7175)
end

function testConnectSendMes()
    msg = OutputMessage.create()
    msg:addString('Hello World!')

    Send:send(msg)

    print('isConnected:  '..tostring(Send:isConnected())) --terminal show true
    print('isConnecting:  '..tostring(Send:isConnecting())) --terminal show false
end

Next I create in first OTClient listener but it doesn't work:
Lua:
local List = Protocol.create()

function testConnectListener()
    List:connect("127.0.0.1", 7175)
end

function testConnectListenerOne()
    print('Recv:  '..List:recv())
end

--Or
testEventServer = {}
function testConnectListener()
    testEventServer['myId'] = cycleEvent(function()
        local xxx = List:recv()
        if xxx then
            print(xxx)
        end
    end, 1)
end

Terminal send (function testConnectListenerOne()) Error: command failed: /modules/terminal_scriptwrite/scripts/target.lua:75: attempt to concatenate a nil value.

Someone have idea how to received messages sended from second to first OTClient?

I check in Process Hacker (network) and I see:
Local Port: 7175 - Listener
Remote Port: 7175 - Established
Remote Port: 7175 - Established

So I think, I connect properly.
 
well this looks really interesting.. i'd like to help with that somehow if i can

are you thinking of creating gamerooms?
did you managed it to work already?
 
my guess is that io_service is not processing scheduled async operations (no .run or .poll is called on that bad boy).
In short, GraphicalApplication needs to be running in order to poll asio's requests.

@edit
Just noticed that this topic was created almost 2 years ago, very good digging @Vagner
 
Last edited:
Back
Top