Raised This Month: $51 Target: $400
 12% 

[EXTENSION] Socket (3.0.1)


Post New Thread Reply   
 
Thread Tools Display Modes
St00ne
Veteran Member
Join Date: Jan 2011
Location: Annecy - France
Old 03-12-2013 , 21:58   Re: [EXTENSION] Socket (3.0.1)
Reply With Quote #401

Thanks a lot, I've just found a few pieces of information on the Internet, but the tips are a little too complicated for me, hopefully some other admins of my team will be able to help me.
(Talking about this:
http://forums.alliedmods.net/showthread.php?t=180528
https://forums.alliedmods.net/showthread.php?t=194032)

Just one thing: if I disable rcon (rcon_password ""), will it work?

I'll consider other solutions later if this works.

Then I'll stop posting in this thread as it's not related to Socket extension.
__________________

*** *** ***
-My plugins-

Last edited by St00ne; 03-12-2013 at 22:02.
St00ne is offline
waylaidwanderer
SourceMod Donor
Join Date: Aug 2012
Old 04-10-2013 , 13:40   Re: [EXTENSION] Socket (3.0.1)
Reply With Quote #402

How do you close the socket connection manually? Currently I have the server application closing it after a set amount of time, but I'd like to do it from the plugin's end.
waylaidwanderer is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-10-2013 , 22:47   Re: [EXTENSION] Socket (3.0.1)
Reply With Quote #403

Wouldn't you just use CloseHandle() on the socket's handle?
bl4nk is offline
Chimera
New Member
Join Date: Apr 2013
Old 04-21-2013 , 17:07   Re: [EXTENSION] Socket (3.0.1)
Reply With Quote #404

Hi there. First off, fantastic work on this extension. Been using it on Linux and it works really well. However...

I'm having an issue using sockets on Windows. The SM plugin I had written that was working on my Linux servers don't work properly on the Windows servers. With the Windows servers, when I call SocketSend, it opens the connection but doesn't send any data... ever. I've checked and it does call the sendqueueempty callback once it's done but no data is actually sent.

The code is simply meant to make a connection and, as soon as the connection is established, send a TCP string and disconnect.

The offending code is as follows:

PHP Code:
someMethod(){
    
//...
    
decl String:notificationString[1024];
    
    
ImplodeStrings(notificationFIELD_COUNTdelimiternotificationStringsizeof(notificationString));
    
    new 
Handle:notificationPack CreateDataPack();
    
WritePackString(notificationPacknotificationString);
    
//...
        
new Handle:socket SocketCreate(SOCKET_TCPOnSocketError);
    
        
SocketSetArg(socketnotificationPack);
        
        
//...

        
SocketConnect(socketOnOutgoingSocketConnectedOnOutgoingSocketReceiveOnOutgoingSocketDisconnectedendpointsAddresses[i], endpointsPorts[i]);
    
}

...

public 
OnOutgoingSocketConnected(Handle:socketany:arg) {    
    
LogMessage("Connected to TCP adapter");
    
ResetPack(arg);
    
    
decl String:notification[1024];
    
ReadPackString(argnotificationsizeof(notification));
    
LogMessage("Sending notification: %s"notification);
    
SocketSend(socketnotification);
}

... 
Again, this works perfectly on Linux but on Windows nothing is actually sent by SocketSend and if I call SocketDisconnect, it causes a connection reset error (at both sides of the connection).

Both the Windows and Linux servers are running MM 1.10, SM 1.5.0, Sockets 3.0.1. The only difference is the OS-specific extensions. Any help on this would be greatly appreciated. Have I just done something stupid or is this an issue with the Windows version? I've seen nothing else like this in this thread so I'm suspecting the former.

Edit: Found that it wasn't terminating the sent data in the same way. So, by changing the way I was reading the data at the receiver and swallowing the connection reset error, I can get it to work. Just a shame that SocketSend doesn't work the same way on both versions of sockets. Sorry I wasted your time reading this if this didn't help you.

Last edited by Chimera; 04-21-2013 at 18:43.
Chimera is offline
Twelve-60
Senior Member
Join Date: Aug 2007
Old 04-29-2013 , 06:44   Re: [EXTENSION] Socket (3.0.1)
Reply With Quote #405

It seems this socket suddenly broke on Windows - not sure how but I am exibiting the same problems as you @chimera, on a previously working plugin (WarMod) before a few CS:GO updates (using the same Sockets version) - a connection but no data sent. Could you maybe elaborate on your solution?
__________________
Twelve-60 is offline
Chimera
New Member
Join Date: Apr 2013
Old 05-01-2013 , 08:02   Re: [EXTENSION] Socket (3.0.1)
Reply With Quote #406

Hi, I found that the data was in-fact being sent, however, the Windows version of Sockets doesn't terminate the connection in the same way as it does on Linux, i.e. the Linux version terminates the sent TCP string with a null character (\0), whereas the Windows version doesn't send the \0 and just stops, leaving the connection hanging.

My solution, which is currently inelegant as I haven't gotten round to tidying it up yet, is to (on the server) read the incoming data into a buffer character by character, have the plugin call the SocketDisconnect on the socket when it thinks it's done sending (which aborts the connection) and have the server just swallow the connection reset error and continue with the data it has in the buffer.

Hope this helps you.
Chimera is offline
davelu
Junior Member
Join Date: Jul 2007
Old 07-11-2013 , 00:30   Re: [EXTENSION] Socket (3.0.1)
Reply With Quote #407

Hey guy,I'm Chinese,I am sorry for my poor english, so please forgive me to talk with you with h ehelp of some tools.

I use MYSQL for while someone join sever,broadcast his IP address
Quote:
#include <sourcemod>
#include <dbi>

#pragma semicolon 1

#define CD_VERSION "1.0"


public Plugin:myinfo =
{
name = "SHAIT IP-ADDRESS",
author = "量子游戏 Dave",
description = "",
version = CD_VERSION,
url = "[IMG]file:///C:/Users/ADMINI~1/AppData/Local/Temp/[5UQ[BL(6~BS2JV6W%7DN6[%25S.png[/IMG]www.shait.net"
}

public OnClientPostAdminCheck(client)
{
if(IsFakeClient(client)) return;

decl String:gName[MAX_NAME_LENGTH+1],
String:gIp[16],
String:gAuth[21];

GetClientName(client, gName, MAX_NAME_LENGTH);
GetClientIP(client, gIp, sizeof(gIp));
GetClientAuthString(client, gAuth, sizeof(gAuth));

new Handle:kv = CreateKeyValues("sql");
KvSetString(kv, "driver", "mysql");
KvSetString(kv, "host", "[IMG]file:///C:/Users/ADMINI~1/AppData/Local/Temp/[5UQ[BL(6~BS2JV6W%7DN6[%25S.png[/IMG]www.shait.net");
KvSetString(kv, "port", "7777");
KvSetString(kv, "database", "ipdb");
KvSetString(kv, "user", "dave");
KvSetString(kv, "pass", "Dave_031");

decl String:error[255];
new Handle:hDatabase = SQL_ConnectCustom(kv, error, sizeof(error), true);
CloseHandle(kv);

if (hDatabase == INVALID_HANDLE)
{
LogError("SQL Connection Failed: %s", error);
return;
}

decl String:query[150];
Format(query, 150, "SELECT address FROM ip WHERE ip1<= INET_ATON('%s') AND ip2>= INET_ATON('%s')", gIp, gIp);
SQL_FastQuery(hDatabase, "SET NAMES \"UTF8\"");
new Handle:queryH = SQL_Query(hDatabase, query);
if(!queryH){
PrintToChatAll("\x01欢迎 \x04来自火星\x01的朋友\x04%s\x01进入量子服务器", gName );
return;
}
decl String:qAddress[150];
SQL_FetchString(queryH, 0, qAddress, sizeof(qAddress));
if(queryH != INVALID_HANDLE){
PrintToChatAll("\x01欢迎来自\x04%s\x01的玩家\x04%s\x 01进入量子服务器", qAddress, gName );
}
else{
LogError("SQL SELECT Failed: %s", error);
}
CloseHandle(queryH);
}
But when many people in the sever,it's mega lag.
So i want to ask a questions,how to send Socket in URL and receive that.
I try to do it,but it's not work.

Quote:
#include <sourcemod>
#include <socket>
#define CD_VERSION "1.0"

public Plugin:myinfo =
{
name = "SHAIT IP-ADDRESS",
author = "量子游戏, Dave",
description = "",
version = CD_VERSION,
url = "www.shait.net"
}
public OnSocketError(Handle:socket, const errorType, const errorNum, any:arg)
{
LogError("socket error %d (errno %d)", errorType, errorNum);
CloseHandle(socket);
}
public OnSocketConnected(Handle:socket, any:arg)
{
SocketSend(socket, "USER MyUserName\r\n");
}

public OnClientPostAdminCheck(client)
{
if(IsFakeClient(client)) return;
decl String:gName[MAX_NAME_LENGTH+1],
String:gIp[16],
String:gAuth[21];

GetClientName(client, gName, MAX_NAME_LENGTH);
GetClientIP(client, gIp, sizeof(gIp));
GetClientAuthString(client, gAuth, sizeof(gAuth));
new Handle:socket = SocketCreate(SOCKET_TCP, OnSocketError);
decl String:qUrl[250];
Format(gUrl, 250, "http://www.youdao.com/smartresult-xm...k&type=ip&q=%s", gIp);
SocketConnect(socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, gUrl, 80);
}
public OnSocketReceive(Handle:socket, String:receiveData[], const dataSize, any:arg)
{
if (!StrContains(receiveData, "location"))
{
PrintToChatAll("显示来自%s的玩家%s", receiveDate, gName );
}
else
{
PrintToChatAll("显示来自火星的玩家%s", gName );
}
}
public OnSocketConnected(Handle:socket, any:arg)
{
SocketSend(socket, gIp);
}
thank you very much
davelu is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 07-11-2013 , 16:30   Re: [EXTENSION] Socket (3.0.1)
Reply With Quote #408

You should use threaded queries instead (http://docs.sourcemod.net/api/index....d=show&id=364& instead of "FastQuery").
Dr. Greg House is offline
cool_myll
SourceMod Donor
Join Date: Aug 2011
Old 07-16-2013 , 08:21   Re: [EXTENSION] Socket (3.0.1)
Reply With Quote #409

https://forums.alliedmods.net/showpo...15&postcount=7

Can you fix the crashes when the server tries to restart for automatic steam update? I think it used the _restart command. It often crashes the server.
__________________
cool_myll is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 07-16-2013 , 10:25   Re: [EXTENSION] Socket (3.0.1)
Reply With Quote #410

Is that on Windows? I'm not having that issue on Linux.
bl4nk is offline
Reply



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 20:37.


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