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 iError, data[ 4 ];
iSocket = socket_open( szHost, iPort, SOCKET_TCP, iError );
if( !iSocket || iError )
{
set_task( 10.0, "SocketInit", 3334 );
return;
}
remove_task( 3334 );
set_task( 1.0, "RecvSocket", 3335, _, _, "b" );
}
public RecvSocket( )
{
if( socket_change( iSocket, 110000 ) )
{
new data[ 512 ];
socket_recv( iSocket, data, charsmax( data ) );
client_print( 0, print_chat, "%s", data );
}
}
public plugin_end( )
socket_close( iSocket );
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.
__________________