Socket plugin procedure in script
#2

You will need to listen for the connection from your C# application. To listen you will need to bind a listener to what ever port you choose to use, and then the server will wait for incoming connections.

Example:
Код:
// DEFINITIONS 
#define SOCKET_MAX_CONNECTIONS 		( 1 ) 		// Change this to what ever limit you wish to use
#define SOCKET_LISTEN_PORT 			( 8000 ) 	// Change this to what ever port you wish to use

// GLOBAL VARS
new 
	Socket:socket
;

public OnGameModeInit()
{
	socket = socket_create( TCP ); // or UDP if your using that protocol

	// Validate it
	if( is_socket_valid( socket ) )
	{
		socket_set_max_connections( socket, SOCKET_MAX_CONNECTIONS ); // Limit the connections to it
		socket_listen( socket, SOCKET_LISTEN_PORT ); // Set the listen/bind port
	}
}

public onSocketRemoteConnect( Socket:id, remote_client[], remote_clientid )
{
	// Check if the socket belongs to you ( validate that its your C# app, if not destroy it )
	// Log it?

	return 1;
}

public onSocketRemoteDisconnect( Socket:id, remote_clientid )
{
	// Log it?
	return 1;
}

public onSocketReceiveData( Socket:id, remote_clientid, data[], data_len )
{
	// Validate the data sent by the socket.
	return 1;	
}
Hopefully this will help you. Remember to close the socket after you are done with it.
Reply


Messages In This Thread
Socket plugin procedure in script - by Saddin - 06.04.2017, 23:05
Re: Socket plugin procedure in script - by azzerking - 06.04.2017, 23:24
Re: Socket plugin procedure in script - by Saddin - 06.04.2017, 23:37
Re: Socket plugin procedure in script - by Saddin - 07.04.2017, 13:48
Re: Socket plugin procedure in script - by Saddin - 08.04.2017, 22:49
Re: Socket plugin procedure in script - by Saddin - 10.04.2017, 15:43

Forum Jump:


Users browsing this thread: 1 Guest(s)