I'm not sure if you can do that with curl, unless you've control over the machine to set up a web server then send http requests in the plugins to store/retrieve data.
You shouldn't be using amxmodx sockets module, it's in blocking mode, which basically means your server will hang up every time you do a request. I used sockets_hz on a few of my projects, check if it works on your server. Threaded sockets seems a good option as well, definitely give it a try.
sockets_hz
linux:
https://forums.alliedmods.net/showthread.php?t=60026
windows:
https://forums.alliedmods.net/showpo...8&postcount=15
threaded sockets
https://forums.alliedmods.net/showth...t=60026&page=2
latest
https://github.com/ShootingKing-AM/T...ckets/releases
Here's a sample plugin made with sockets_hz, tested on a local windows server
server
Code:
#include <amxmodx>
#include <sockets_hz>
new const HOST[] = "127.0.0.1"
const PORT = 4444
new g_server
public plugin_init()
{
new error
g_server = socket_listen(HOST, PORT, SOCKET_TCP, error)
if (g_server <= 0)
{
server_print("^t socket_listen() failed: error %d", error)
}
else
{
server_print("^t server listening on %s:%d", HOST, PORT)
socket_unblock(g_server)
set_task(1.0, "Listen", .flags = "b")
}
}
public plugin_end()
{
if (g_server > 0)
{
socket_close(g_server)
}
}
public Listen()
{
new client = socket_accept(g_server)
if (client <= 0)
{
return
}
server_print("^t [%.2f] client connected", get_gametime())
socket_unblock(client)
set_task(1.0, "RecvData", client, .flags = "b")
}
public RecvData(client)
{
if (!socket_change(client, 0))
{
return
}
new buffer[1024]
new bytes = socket_recv(client, buffer, sizeof buffer)
switch (bytes)
{
case -1:
{
// error
server_print("^t [%.2f] socket_recv() failed", get_gametime())
}
case 0:
{
// connection closed
server_print("^t [%.2f] client disconnected", get_gametime())
socket_close(client)
remove_task(client)
}
default:
{
server_print("^t received %d bytes", bytes)
server_print("^t --------------------------")
server_print("^t %s", buffer)
server_print("^t --------------------------")
copy(buffer, charsmax(buffer), "send this back to the client")
bytes = socket_send(client, buffer, sizeof buffer)
server_print("^t sent %d bytes", bytes)
}
}
}
client
Code:
#include <amxmodx>
#include <sockets_hz>
new const HOST[] = "127.0.0.1"
const PORT = 4444
public plugin_init()
{
new error
new client = socket_open(HOST, PORT, SOCKET_TCP, error)
if (client <= 0)
{
server_print("^t socket_open() failed: error %d", error)
}
else
{
socket_unblock(client)
new const data[] = "send this to the server"
new bytes = socket_send(client, data, sizeof data)
if (bytes == -1)
{
// error
server_print("^t socket_send() failed")
socket_close(client)
}
else
{
set_task(1.0, "RecvResponse", client, .flags = "b")
}
}
}
public RecvResponse(client)
{
if (!socket_change(client, 0))
{
return
}
new buffer[1024]
new bytes = socket_recv(client, buffer, sizeof buffer)
switch (bytes)
{
case -1:
{
// error
server_print("^t [%.2f] socket_recv() failed", get_gametime())
}
case 0:
{
// connection closed
server_print("^t connection closed", get_gametime())
}
default:
{
server_print("^t received %d bytes", bytes)
server_print("^t --------------------------")
server_print("^t %s", buffer)
server_print("^t --------------------------")
}
}
socket_close(client)
remove_task(client)
}
This uses the TCP protocol. UDP would be faster, you probably wouldn't have problems with it as the server and client are both on the same machine, but with the current natives available in the sockets_hz module, it is only possible to
recv on a UDP listening socket, you can't
send a response unless you run both, the socket server and client on both game servers, but on different ports.
If sockets isn't an option for you, I'm not sure if it's possible to read files outside the server directory through a plugin. I can't think of a simple solution to the problem, you would need an intermediate between the two servers, either a database server with the sqlx module or a http server with the curl module.
If you've access to the machine, you could set up an automated task to copy files from one to the other.
__________________