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

Module: Threaded Sockets


Post New Thread Reply   
 
Thread Tools Display Modes
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 08-31-2016 , 15:47   Re: Module: Threaded Sockets
Reply With Quote #51

Maybe create a way to send payloads to the Redis server one at a time, but cache chat messages in between each "push" to the Redis server, then send multiple of them.
klippy is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 09-01-2016 , 05:44   Re: Module: Threaded Sockets
Reply With Quote #52

As Klippy said, Update your Redis server at regular intervals. In between those intervals, cache chat messages from all clients in dynamic memory buffer(program variables) or secondary storage(files). When the update takes place, send all the contents of file or array to your server and clear the contents of the buffers.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 12-09-2016 , 14:42   Re: Module: Threaded Sockets
Reply With Quote #53

Using your TSocksListenAccept plugin, the server crashes when I spam (holding ctrl + r) refresh through my web browser.

I only modified the port ip/port and confirmed that the server receives the connection. No other plugins are running.

The same thing happens when I use this module: https://forums.alliedmods.net/showthread.php?t=289967
PartialCloning is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 12-11-2016 , 02:26   Re: Module: Threaded Sockets
Reply With Quote #54

Omg Are you trying to Dos your own server ?? XD That was just an example showing how to use some functions of the module, What do you want to accomplish actually ?
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 12-16-2016 , 00:58   Re: Module: Threaded Sockets
Reply With Quote #55

I just wanted to see if it was possible to low key emulate the webserver module using your sockets module. However it seems the crash might be due to something on my end, as Klippy is saying it does not crash for him using the script I provided that almost instantly crashes every time for me when spamming refresh.
PartialCloning is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 12-16-2016 , 05:41   Re: Module: Threaded Sockets
Reply With Quote #56

Quote:
Originally Posted by PartialCloning View Post
I just wanted to see if it was possible to low key emulate the webserver module using your sockets module
Can you explain more on this topic
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 12-16-2016 , 19:15   Re: Module: Threaded Sockets
Reply With Quote #57

I was trying to display the motd.txt file to the client if they visit the server's main ip through a web browser. A similar sourcemod extension was used to make a real time web based scoreboard that looks like this, so eventually I wanted to display more than just the motd through the server's ip on a web browser.
PartialCloning is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 12-21-2016 , 04:12   Re: Module: Threaded Sockets
Reply With Quote #58

Code for what you had done till now ?
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 05-17-2017 , 03:11   Re: Module: Threaded Sockets
Reply With Quote #59

Code:
#include <amxmodx> #include <sockets> new const szListenAddr[] = "192.168.2.2"; new const iListenPort = 27015; new g_iThreadHandle = 0, g_ClientSThread = 0; public plugin_init() {     g_iThreadHandle = socket_create_t();         if( socket_listen_t(g_iThreadHandle, szListenAddr, iListenPort, SOCKET_TCP, "CBSocketListen" ) < 0 )     {         log_amx( "Error: Could not listen on %s:%d", szListenAddr, iListenPort );         return;     }     log_amx( "Trying to listen on %s:%d", szListenAddr, iListenPort ); } public CBSocketListen( iThreadState , iReturn ) {     if( iReturn < 0 )     {         log_amx( "Error: Could not listen on %s:%d. Error[%d] : %d", szListenAddr, iListenPort, iReturn );     }     else     {         log_amx( "Listening on %s:%d. Waiting to accept connection ...", szListenAddr, iListenPort );         if( socket_accept_t( g_iThreadHandle, "CBSocketAccept" ) < 0 )         {             log_amx( "Error: Could not accept connection." );         }     } } public CBSocketAccept( iThreadState, iReturn, szClientAddr[], iClientAddrLen, clientport ) {     if( iReturn < 0 )     {         log_amx( "Error: Could not accept connection. Error[%d] : %d", iReturn, socket_get_last_error_t(g_iThreadHandle) );     }     else     {         log_amx( "Accepted Connection from %s[%d]:%d", szClientAddr, iClientAddrLen, clientport );         socket_accept_t(g_iThreadHandle, "CBSocketAccept");                 //iReturn is the new Client Socket.         g_ClientSThread = socket_create_t();         socket_set_sd_t( g_ClientSThread, iReturn );         new szData[] = "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nHello, world!\r\n\r\n";         if( socket_send_t( g_ClientSThread, szData, strlen(szData), "CBClientSendHandler" ) < 0 )         {             log_amx( "Error: Could not send data(%s) to client.", szData );         }     } } public CBClientSendHandler( iThreadState, iReturn ) {     if( iReturn > 0 )     {         log_amx( "Data has been sent to client. Closing Client Socket ..." );         socket_close_t(g_ClientSThread, "CBClientCloseSocket" );     }     else     {         log_amx( "Error: Could not send data(%s) to client. Error[%d] : %d", iReturn, socket_get_last_error_t(g_ClientSThread) );     } } public CBClientCloseSocket( iThreadState, iReturn ) {     socket_destroy_t(g_ClientSThread); } public plugin_end() {     if( g_iThreadHandle )     {         socket_destroy_t(g_iThreadHandle);     } }

I am trying to send back a http response, but I get nothing on my web browser. The server does print "Data has been sent to client. Closing Client Socket ...".
PartialCloning is offline
Shooting King
RAAASENGAN
Join Date: Mar 2012
Location: India
Old 05-17-2017 , 12:19   Re: Module: Threaded Sockets
Reply With Quote #60

Quote:
Originally Posted by PartialCloning View Post
new szData[] = "HTTP/1.0 200 OK\r\nContent-Type: text/plain\r\nHello, world!\r\n\r\n";
In pawn it's not \r\n but it's ^r^n. Try it and let me know
.
__________________
As every time said, don't ever UNDERESTIMATE me.

Donate - Here
Shooting King 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 08:56.


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