theoretical example receiver plugin listens on port 2nd:19133 sender plugin will just send something to 2nd:19132 receiver plugin will phrases the massage and execute it, if it is a valid authenticated command
I now connected using this: But how can I accept it from another server and send a message? PHP: <?php if(!($sock = socket_create(AF_INET, SOCK_STREAM, 0))){ $errorcode = socket_last_error(); $errormsg = socket_strerror($errorcode); die("Couldn't create socket: [$errorcode] $errormsg \n");} echo "Socket created \n"; if(!socket_connect($sock , '0.0.0.0' , 19132)){ $errorcode = socket_last_error(); $errormsg = socket_strerror($errorcode); die("Could not connect: [$errorcode] $errormsg \n");} echo "Connection established \n"; ?>
no not 19132 you need another port where your plugin will open a listening stream on(so means php need root) something like fput or streamput not very certain what it called but you would put some msg example (auth code)-(send to player)-(msg here) auth code is just some mockup way to prevent unauthorized people using it to spam players
PHP: $message = "YourMessage";//Send the message to the serverif( ! socket_send ( $sock , $message , strlen($message) , 0)){ $errorcode = socket_last_error(); $errormsg = socket_strerror($errorcode); die("Could not send data: [$errorcode] $errormsg" . PHP_EOL);}echo "Message send successfully" . PHP_EOL;
Check this: https://github.com/pmmp/RakLib/blob/master/server/UDPServerSocket.php Check readPacket() and writePacket() that is how pocketmine sends and receives packets. Basically strings packed into binary.