Raised This Month: $7 Target: $400
 1% 

Module: Threaded Sockets


Post New Thread Reply   
 
Thread Tools Display Modes
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 05-17-2017 , 17:11   Re: Module: Threaded Sockets
Reply With Quote #61

Quote:
Originally Posted by Shooting King View Post
In pawn it's not \r\n but it's ^r^n.
Yeah, but @PartialCloning can just specify
Code:
#pragma ctrlchar '\'
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
PartialCloning
Senior Member
Join Date: Dec 2015
Old 05-17-2017 , 19:20   Re: Module: Threaded Sockets
Reply With Quote #62

Quote:
Originally Posted by Shooting King View Post
In pawn it's not \r\n but it's ^r^n. Try it and let me know
.
Still nothing.

The server prints "Accepted Connection from ..", "Data has been sent to client. Closing Client Socket ..."

Chrome prints

"This site can’t be reached
The connection was reset."

Edited:
Removing "socket_close_t(g_ClientSThread, "CBClientCloseSocket" );" works, but it seems it's the way http works and you have to wait until all the data is pushed before closing the socket. Is there a way to check when the data is pushed?

It's safe to guess http support wasn't intended in this module. Do you recommend any other module/method to display server information to web browsers using the server's own ip address?

Last edited by PartialCloning; 05-18-2017 at 23:47.
PartialCloning is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 05-19-2017 , 01:59   Re: Module: Threaded Sockets
Reply With Quote #63

Quote:
Originally Posted by PartialCloning View Post
Removing "socket_close_t(g_ClientSThread, "CBClientCloseSocket" );" works, but it seems it's the way http works and you have to wait until all the data is pushed before closing the socket. Is there a way to check when the data is pushed?
The Forward is called after sending data through the socket.

Quote:
Originally Posted by PartialCloning View Post
It's safe to guess http support wasn't intended in this module. Do you recommend any other module/method to display server information to web browsers using the server's own ip address?
This is a generic Threaded Sockets module, meaning it supports all higher level protocols including HTTP, i.e, if the protocol is implemented properly. What you are doing is Correct, guess you are missing somethings. I didn't test your plugin till now, will get back after a quick test.

EDIT: The plugin is working properly as tested with the PHP Script (TCP Connections tester in first post). You are not implementing the HTTP protocol in the plugin properly, also ListenIP is your local ip and Listen Port must be 80 for HTTP. Simply sending HTTP OK will not work i guess, first you have to accept connection, wait for the HTTP Request, Then based upon the request you have to send the response.
BlackRose is also working on a similar HTTP Library, i guess.
As far as Sockets and Module, is concerned they are working as they should, discussion about HTTP is out of scope of this thread, maybe you can open a thread in Scripting Help Section.
Attached Thumbnails
Click image for larger version

Name:	am.PNG
Views:	206
Size:	17.2 KB
ID:	162856  
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here

Last edited by Shooting King; 05-19-2017 at 03:48.
Shooting King is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 05-11-2019 , 01:10   Re: Module: Threaded Sockets
Reply With Quote #64

Hello, I was looking at this module for its threaded sockets function as I am making a webchat/realtime chat app, I was having issues as even AMXX 1.9 sockets caused me +30ms ping in order to read from the socket in a timely manner (0.5s task/thinking entity)

When trying to run this module, I ran into issues creating the socket.. I don't think that the developer is around anymore, but hopefully someone in the AMXX community has an alternative to get 'working threaded sockets' under AMXX.

This is the code I am trying.

PHP Code:
public Socket_Connect()
{

    new 
hostname[33];
    
get_cvar_string("hostname"hostnamecharsmax(hostname));

    
copy(server_namecharsmax(server_name), hostname);
    
//format(g_ServerAddress, charsmax(g_ServerAddress), "0.0.0.0:27000");

    
CheckBot();

    
g_socket socket_create_t();

    if((
socket_open_t(g_socket"M.Y.I.P."32650SOCKET_TCP"Open_Socket")) < 0)
        
server_print"ERROR: Could not open Socket. %d"socket_get_last_error_t(g_socket) );
    else 
server_print("Opening socket...");

}

public 
Socket_OpeniThreadStateiReturn)
{
    
server_print("Socket_Open");
    if( 
iReturn )
    {
        
log_amx"ERROR: Could not open Socket. Error[%d] : %d"iReturnsocket_get_last_error_t(g_socket) );
    }
    else
    {
        new 
packet[256];
        
formatex(packetcharsmax(packet), ".login ^"%s^"^n.server %s^n.password Some Unique String^n"server_nameg_ServerAddress);

        if((
socket_send_t(g_socketpacketcharsmax(packet), "Socket_Send")) < 0)
        {
            
server_print("Could not send data.");
        }
    }
}
public 
Socket_SendiThreadStateiReturn )
{
    if (
iReturn 0)
    {
        
log_amx"ERROR: Error Sending Data. Error[%d] : %d"iReturnsocket_get_last_error_t(g_socket) );
    }
    else
    {
        if ((
socket_recv_t(g_socket"Socket_Receive"512)) < 0)
        {
            
server_print("Issues recieving data");
        }
    }
}
public 
Socket_ReceiveiThreadStateiReturnszRecvData[], iRecvDataLen )
{
    if(
iReturn == 0)
    {
        
server_print("Socket Closed!");
        
socket_close_t(g_socket"Socket_Close");
    }
    else if (
iReturn 0)
    {
        
server_print"ERROR: Error while receiveing data. Error[%d] : %d"iReturnsocket_get_last_error_t(g_socket) );
        
socket_close_t(g_socket"Socket_Close");
    }
    else
    {
        
server_print("Successfully Received Data[%d] : Received - %d "iRecvDataLenszRecvDatastrlen(szRecvData));
    }
}
public 
Socket_CloseiThreadStateiReturn )
{
    
socket_destroy_t(g_socket);

and the response.
Code:
In socket_create_t, creating thread obj
In socket_create_t, creating thread
In socket_create_t, attaching thread
In socket_create_t, adding thread item thread
in CThreadedSocketManager::AddItemToList, before
Start ((nil)) ((nil)) END
in CThreadedSocketManager::AddItemToList, Adding item to list with id 0 Addr 0x99473d0
item-Pev = (nil) end : (nil)
item-Pev = (nil) end : (nil)
in CThreadedSocketManager::AddItemToList, after
Start (0x99473d0) | (nil) (0x99473d0) (nil) | (0x99473d0) END
In socket_create_t, returning cast thread 160723920[4]
In Threadmain, arg - 160723920
In ThreadMain, state is 7
In socket_open_t, De-Casting rc
In socket_open_t, De-Casting rc 160723920[4]
In socket_open_t, Assigining hn 66.151.244.170[66.151.244.170]
In socket_open_t, Assigining port
In socket_open_t, Assigining proto
In socket_open_t, Assigining fid
ERROR: Could not open Socket. -1
__________________
+|- KARMA Respectively

HLM is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 05-11-2019 , 10:04   Re: Module: Threaded Sockets
Reply With Quote #65

Quote:
Originally Posted by HLM View Post
Code:
if((socket_open_t(g_socket, "M.Y.I.P.", 32650, SOCKET_TCP, "Open_Socket")) < 0)
Code:
public Socket_Open( iThreadState, iReturn)
Seems like the module could not find the Public CallbackHandler "Open_Socket". Trying keeping the CallbackHandler name same.

Also to confirm the same try logging out the return value of socket_open_t(), should be -2.

Example,
Code:
iRet = socket_open_t(g_socket, "M.Y.I.P.", 32650, SOCKET_TCP, "Open_Socket")
amx_log(iRet)

if(iRet =.... ) ....
And since the return value of lastSocketError is -1, and doesn't correspond to any ERROR Codes mentioned in 1st Post, I will safely assume that there is no problem with WinSock/LinuxSock APIs

Quote:
Originally Posted by HLM View Post
Code:
In socket_create_t, creating thread obj
In socket_create_t, creating thread
In socket_create_t, attaching thread
In socket_create_t, adding thread item thread
in CThreadedSocketManager::AddItemToList, before
Start ((nil)) ((nil)) END
in CThreadedSocketManager::AddItemToList, Adding item to list with id 0 Addr 0x99473d0
item-Pev = (nil) end : (nil)
item-Pev = (nil) end : (nil)
in CThreadedSocketManager::AddItemToList, after
Start (0x99473d0) | (nil) (0x99473d0) (nil) | (0x99473d0) END
In socket_create_t, returning cast thread 160723920[4]
In Threadmain, arg - 160723920
In ThreadMain, state is 7
In socket_open_t, De-Casting rc
In socket_open_t, De-Casting rc 160723920[4]
In socket_open_t, Assigining hn 66.151.244.170[66.151.244.170]
In socket_open_t, Assigining port
In socket_open_t, Assigining proto
In socket_open_t, Assigining fid
Missing Line: In socket_open_t, Assigining TS
ERROR: Could not open Socket. -1
That must also be the reason why "In socket_open_t, Assigining TS" Assigning ThreadState line didn't get debugged out.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here

Last edited by Shooting King; 05-11-2019 at 10:11.
Shooting King is offline
milutinke
AlliedModders Donor
Join Date: Jun 2012
Location: Serbia
Old 11-10-2019 , 16:38   Re: Module: Threaded Sockets
Reply With Quote #66

The module does not load on Linux i386.
I've checked that the file is a valid one on the server.

Can someone compile the Linux version which works?

Edit: The Debug version works, but is spams the console like crazy.

Last edited by milutinke; 11-10-2019 at 17:08.
milutinke is offline
Send a message via Skype™ to milutinke
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 01-07-2020 , 16:17   Re: Module: Threaded Sockets
Reply With Quote #67

Quote:
Originally Posted by milutinke View Post
The module does not load on Linux i386.
I've checked that the file is a valid one on the server.

Can someone compile the Linux version which works?

Edit: The Debug version works, but is spams the console like crazy.
Somemore details maybe ? Like what distro of linux are you using. Amxx version ? Amxx modules ? What does the the console say ?

The release version and debug were compiled on the same platform + compiler
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
PredatorBlock
AlliedModders Donor
Join Date: Apr 2020
Old 10-15-2020 , 17:39   Re: Module: Threaded Sockets
Reply With Quote #68

[AMXX] Module "cstrike/addons/amxmodx/modules/sockets_amxx_i386.so" failed to load (cstrike/addons/amxmodx/modules/sockets_amxx_i386.so: undefined symbol: pthread_create)

[AMXX] Module is not a valid library (file "cstrike/addons/amxmodx/modules/sockets_amxx_i386.so")

[AMXX] Plugin "test.amxx" failed to load: Module/Library "sockets" required for plugin. Check modules.ini.
PredatorBlock is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 10-17-2020 , 23:20   Re: Module: Threaded Sockets
Reply With Quote #69

Quote:
Originally Posted by GGzone View Post
[AMXX] Module "cstrike/addons/amxmodx/modules/sockets_amxx_i386.so" failed to load (cstrike/addons/amxmodx/modules/sockets_amxx_i386.so: undefined symbol: pthread_create)

[AMXX] Module is not a valid library (file "cstrike/addons/amxmodx/modules/sockets_amxx_i386.so")

[AMXX] Plugin "test.amxx" failed to load: Module/Library "sockets" required for plugin. Check modules.ini.
Which distribution are you running ? Did you compile the module yourself ?
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
Old 10-29-2020, 08:24
pizzahut
This message has been deleted by pizzahut.
wopox3
Junior Member
Join Date: Dec 2013
Location: Russia
Old 11-17-2020 , 23:35   Re: Module: Threaded Sockets
Reply With Quote #70

Quote:
Originally Posted by PredatorBlock View Post
[AMXX] Module "cstrike/addons/amxmodx/modules/sockets_amxx_i386.so" failed to load (cstrike/addons/amxmodx/modules/sockets_amxx_i386.so: undefined symbol: pthread_create)

[AMXX] Module is not a valid library (file "cstrike/addons/amxmodx/modules/sockets_amxx_i386.so")

[AMXX] Plugin "test.amxx" failed to load: Module/Library "sockets" required for plugin. Check modules.ini.
Having the same problem. Using binaries from 1st post.
Code:
Linux 38a4062eab23 5.4.39-linuxkit #1 SMP Fri May 8 23:03:06 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"

Last edited by wopox3; 11-18-2020 at 00:17.
wopox3 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 23:59.


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