AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problems with sockets (https://forums.alliedmods.net/showthread.php?t=185552)

Neeeeeeeeeel.- 05-19-2012 01:49

Problems with sockets
 
Hello :D

I make this little plugin... I'm noob at sockets.

PHP Code:

#include <amxmodx>
#include <sockets>

new const szHost[ ] = "localhost";
const 
iPort 2643;

new 
iSocket;

public 
plugin_init( )
{
    
register_plugin"Socket Test""v1.0""Neeeeeeeeeel.-" );
    
    
SocketInit( );
}

public 
SocketInit( )
{
    new 
iErrordata];
    
    
iSocket socket_openszHostiPortSOCKET_TCPiError );
    
    if( !
iSocket || iError )
    {
        
set_task10.0"SocketInit"3334 );
        return;
    }
    
    
remove_task3334 );
    
    
set_task1.0"RecvSocket"3335__"b" );
}

public 
RecvSocket( )
{
    if( 
socket_changeiSocket110000 ) )
    {
        new 
data512 ];
        
        
socket_recviSocketdatacharsmaxdata ) );
        
        
client_print0print_chat"%s"data );
    }
}

public 
plugin_end( )
    
socket_closeiSocket ); 

And I connected with an application in visual basic. Works fine... when de plugin creates the connection it shows me (in de applitacion) a notification.

The problem is... How can I know (in pawn) if the app is running in my computer or not? Because the socket open withour errors while the app it is close. Because if I execute socket_open while the app is close and then I open my app I cannot sent messages to the server. Do you understand what I mean?

If it is not clear tell me:3

Edit: New problem... I was working with localhost... but now I try with my IP and a server in other PC, if the app is not open the server freeze for 10 sec (more or less) when it execute socket_open, why? how can I solve it? :/

Thanks.


All times are GMT -4. The time now is 00:20.

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