Unable to do telnet to php socket code -
i created php program listen port.here php code
<?php if(!($sock = socket_create(af_inet, sock_dgram, 0))) { $errorcode = socket_last_error(); $errormsg = socket_strerror($errorcode); die("couldn't create socket: [$errorcode] $errormsg \n"); } echo "socket created \n"; if( !socket_bind($sock, "192.168.0.177" , 5060) ) { $errorcode = socket_last_error(); $errormsg = socket_strerror($errorcode); die("could not bind socket : [$errorcode] $errormsg \n"); } echo "socket bind ok \n"; while(1) { echo "waiting data ... \n"; $r = socket_recvfrom($sock, $buf, 512, 0, $remote_ip, $remote_port); echo $buf; } ?>
but when telnet 192.168.0.177 5060
message
could not open connection host on port 5060
i checked telnet service , running fine.
that's because open udp socket, , telnet
uses tcp.
Comments
Post a Comment