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

[SOCKET] Sending messages between servers help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Eden.Campo
Member
Join Date: Mar 2013
Old 07-25-2013 , 07:36   [SOCKET] Sending messages between servers help
Reply With Quote #1

Hello there!

I've tried using socket for my plugins today, and it went quite fine, but for some reason I cant get SocketReceive func called, never.

Code:
new Handle:Socket;


public Action:Command_SubNeeded(client, args)
{
	new port = StringToInt(DestPort);

	Socket = SocketCreate(SOCKET_TCP, OnSocketError);
	
	SocketConnect(Socket, OnSocketConnected, OnSocketReceive, OnSocketDisconnected, Dest, port);
	
	CreateTimer(1.0, Timer_SendPacket);
	
	return Plugin_Handled;
}

public OnSocketError(Handle:sock, const errorType, const errorNum, any:arg)
{
	LogError("socket error %d (errno %d)", errorType, errorNum);
	CloseHandle(sock);
}

public OnSocketConnected(Handle:sock, any:arg)
{
	#if defined DEBUG
	CPrintToChatAll("[Debug] Fired OnSocketConnected();");
	#endif
}

public OnSocketReceive(Handle:sock, String:receiveData[], const dataSize, any:arg)
{
	PrintToChatAll("%s", receiveData);
	
	#if defined DEBUG
	CPrintToChatAll("[Debug] Fired OnSocketReceive();");
	#endif
	
	CloseHandle(sock);
}

public OnSocketDisconnected(Handle:sock, any:arg)
{
	CloseHandle(sock);
	
	#if defined DEBUG
	CPrintToChatAll("[Debug] Fired OnSocketDisconnected();");
	#endif
}

public Action:Timer_SendPacket(Handle:timer)
{
	decl String:requestStr[256];
	Format(requestStr, sizeof(requestStr), "This is a test between servers");
	SocketSend(Socket, requestStr, 256);
	
	#if defined DEBUG
	CPrintToChatAll("[Debug] Fired Timer_SendPacket(%s);", requestStr);
	#endif
}
As a result, I get the following in my serv(IP and Port are correct)

[Debug] Fired OnSocketConnected();
[Debug] Fired Timer_SendPacket(This is a test between servers);
[Debug] Fired OnSocketDisconnected();

But i never get the actual PrintToChat message.

-
Thanks, Eden
Eden.Campo is offline
Bittersweet
Veteran Member
Join Date: May 2012
Old 07-26-2013 , 17:37   Re: [SOCKET] Sending messages between servers help
Reply With Quote #2

If there is nothing in your error logs relating to this, then you probably are getting the chat message but the string is empty. Try something like PrintToChatAll("Message=%s, length=%i", receiveData, sizeof(receiveData)); as a test.
__________________
Thank you in advance for your help

My plugins:
[CS:S] BOT Swat | [ANY] CVAR Randomizer | [CS:S] SM CS:S Tag Beta | [CS:S] Bot2Player
Awesome & Crucial plugins by other people:
[CS:S/CS:GO] GunGame | [UMC3] Ultimate Mapchooser | [ANY] Server Crontab | [ANY] SM ForceCamera
Bittersweet 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 20:45.


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