AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=58)
-   -   Sourcepawn sockets with python (https://forums.alliedmods.net/showthread.php?t=322850)

Raicha 04-05-2020 16:42

Sourcepawn sockets with python
 
OpenSocketStream()
{
new String:serverIP[40];
new longip = GetConVarInt(FindConVar("hostip"));
FormatEx(serverIP, 40, "%d.%d.%d.%d", longip >>> 24 & 255, longip >>> 16 & 255, longip >>> 8 & 255, longip & 255);
if (!ServerSocket)
{
ServerSocket = Websocket_Open(serverIP, GetConVarInt(CVAR_WebsocketPort), OnWebsocketIncoming, OnWebsocketMasterError, OnWebsocketMasterClose);
}
PrintToChatAll("OCTET FLOW STREAM STARTED ! NUDGE OFFSET %i", GetConVarInt(CVAR_WebsocketPort));
return 0;
}

public void:OnPluginStart()
{
CVAR_WebsocketPort = CreateConVar("sm_discord_port", "1337", "WEBSOCKET PORT", 0, false, 0.0, false, 0.0);
ClientSockets = CreateArray(1, 0);
RegAdminCmd("1337wh", SLK, 16384, "", "", 0);
RegConsoleCmd("link", Command_RootAcc, "", 0);
return void:0;
}

I am trying to connect to that socket in python, but it fails, by hanging on. Python code is -
import socket
import json

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

x = '{"RequestType":"35","RemoteLinkPKG":"POST"," RemoteLinkPKG":"1337","SID":"1234","Time":"12 34","Action"."1"}'
y = json.dumps(x)
s.connect(('localhost',1337))
s.send(y)
print s.recv(1024)

Fyren 04-06-2020 12:53

Re: Sourcepawn sockets with python
 
Websockets are not the same thing as sockets.


All times are GMT -4. The time now is 06:13.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.