mIRC Home    About    Download    Register    News    Help

Print Thread
#258027 05/06/16 11:50 AM
T
TillableToast
TillableToast
T
Hi so I'm currently working on a way to make a dashboard for my bot. My idea is that I have my website send commands to the bot via sockets though I'm having some trouble.

This is the code that sends the message to my bot (Note this is PHP)
Code:
function sendMsg($msg) {
  $host = "myIp";
  $port = myPort;
  $len = strlen($msg);
  $socket = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
  socket_connect($socket,$host,$port) or die("Could not connect to the socket\n");
  socket_sendto($socket, $msg, $len, 0, $host, $port);
}

Basically what it does is that it sends a string to my VPS which the bot is hosted on, then the bot reads it using this code:
Code:
on *:SOCKLISTEN:www: {  
  sockaccept web $+ $ticks 
  echo -s *** Connection Accepted. 
}
on *:SOCKREAD:web*: { 
  echo -s *** READING MESSAGE
  sockread %msg 
  echo -s MESSAGE: %msg
}


So when I run the PHP code my bot does actually run through the socket events, though it does not fetch the message, it only echoes: MESSAGE: (blank)

NOTE: I have indeed opened up the ports on both ends so it's not a firewall issue

Hope someone out there can help me

Last edited by TillableToast; 05/06/16 11:53 AM.
Joined: Jan 2004
Posts: 1,330
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,330
Are the messages terminated with a linebreak?

T
TillableToast
TillableToast
T
No, it just sends the message on line 1 I would assume

F
Fonic_Artes
Fonic_Artes
F
Question:
Is %msg being assigned a value?

T
TillableToast
TillableToast
T
Yes ofc smile I just do that by calling the function and parsing it a value like this: sendMsg($message);

EDIT: The %msg variable is equal to what it reads on the socket

Last edited by TillableToast; 05/06/16 12:18 PM.

Link Copied to Clipboard