Raised This Month: $ Target: $400
 0% 

Problems with sockets


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 05-19-2012 , 01:49   Problems with sockets
Reply With Quote #1

Hello

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

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.
__________________

Last edited by Neeeeeeeeeel.-; 05-19-2012 at 04:02.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Reply



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 00:20.


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