Raised This Month: $ Target: $400
 0% 

socket_read


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-03-2011 , 15:44   socket_read
Reply With Quote #1

PHP Code:
public socket_init()
{
    new 
ip[64],port,erre,user[32],pass[100]
    new 
cmd[300];
    
get_cvar_string("cm_bot_host",ip,63)
    
port get_cvar_num("cm_bot_port")
    
bothost socket_open(ip,port,SOCKET_TCP,erre)
    if (
erre == 0) {
        
remove_taskRETRY );
    
server_print("Socket Reopened");
    }
    else {
         
socket_close(bothost);
         return 
PLUGIN_HANDLED
    
}
    
    new 
params];
    
params] = bothost;
    
set_task2.5 "socket_read" TASK_RECV params sizeofparams ) , "b" );
    return 
PLUGIN_CONTINUE;
}
new 
socket_status[50]

public 
socket_read(botcmd[])
{
   if ( 
socket_changebothost ) )
   {
   
socket_recv(bothost,botcmd,500)

   if (
equal(botcmd,"")) {
       
server_print("[Network] Connection with Bot has been lost");
       
socket_close(bothost);
       new 
params[9];
       
params[1] = RETRY;
       
set_task1.50 "socket_init" RETRY params sizeofparams ) , "b" );
       
remove_taskTASK_RECV );
   }
   
server_print("[Gather] %s",botcmd); 

Well i have a small problem on Socket Read, everytime that it reads data from socket evey user's latency raises 20... Any idea to solve it ? :s

p.s last year that i had made a socket code [i have lost it] it didn't raised the latency...
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-03-2011 , 15:52   Re: socket_read
Reply With Quote #2

May be you loose the connexion each time and it reconnects each time ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-03-2011 , 15:58   Re: socket_read
Reply With Quote #3

My Server Side Program [that the plugin connected to] is not closing the connection and my console is showing to me that the socket is still open...
If the connection closed the Server Side program will ask for authentication..
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-07-2011 , 12:07   Re: socket_read
Reply With Quote #4

socket_recv(bothost,botcmd,500)

I thing on this command the ping raises..
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-22-2011 , 11:37   Re: socket_read
Reply With Quote #5

bump
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons is offline
BAILOPAN
Join Date: Jan 2004
Old 04-24-2011 , 02:39   Re: socket_read
Reply With Quote #6

socket_change has a default timeout parameter of 100000µs, which is 100ms. That means it has the potential to block the game server for 100ms, which is a long amount of time - like an entire 10 frames on a high-ticrate server. You might want to lower it to like 1000 or 500?
__________________
egg
BAILOPAN is offline
ProIcons
Senior Member
Join Date: Jan 2009
Location: Greece - Salonica
Old 04-24-2011 , 04:39   Re: socket_read
Reply With Quote #7

oh well thank you very very much D
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))
ProIcons 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 14:38.


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