Raised This Month: $32 Target: $400
 8% 

Sourcepawn sockets with python


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Raicha
New Member
Join Date: Apr 2020
Old 04-05-2020 , 16:42   Sourcepawn sockets with python
Reply With Quote #1

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)

Last edited by Raicha; 04-06-2020 at 00:57.
Raicha is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-06-2020 , 12:53   Re: Sourcepawn sockets with python
Reply With Quote #2

Websockets are not the same thing as sockets.
Fyren is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:52.


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