Im learning php socket.. as you can see.. but i have a problem.. im tring to test it out.. by telneting to the scripts.. port.. but i keep getting Could not open a connection to { ip } can anyone help
$address = "127.0.0.1";
$port = 8080;
set_time_limit( 0 );
if(( $socket = socket_create( AF_INET, SOCK_STREAM, 0 )) < 0 )
{
echo "socket_create( ): Faild: Reason: ( $socket ): ". scoket_strerror( );
}
if(( $bind = socket_bind( $socket, $address, $port )) < 0 )
{
echo "socket_bind( ): Faild: Reason: ( $bind ): ". scoket_strerror( );
}
if(( $listen = socket_listen( $socket, 3 )) < 0 )
{
echo "socket_listen( ): Faild: Reason: ( $listen ): ". scoket_strerror( );
}
if(( $accept = socket_accept( $socket )) < 0 )
{
echo "socket_accept( ): Faild: Reason: ( $accept ): ". scoket_strerror( );
}
if(( $read = socket_read( $socket, 1024 )) < 0 )
{
echo "socket_read( ): Faild: Reason: ( $read ): ". scoket_strerror( );
}
socket_write( $accept, $read, strlen( $read ));
socket_close( $accept );
socket_close( $socket );
echo $address;
I know some of you seen a code like this similar but.. ya.. i coded this one.. and i love the still it is.. this is why it looks the same .. thanx for the style creater =) its more neater