06.04.2017, 23:24
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:
Hopefully this will help you. Remember to close the socket after you are done with it.
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;
}

