3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * PHP Sockets - How to create a TCP/IP socket client */ echo "<h2>TCP/IP Connection</h2><br />"; /* Get the port for the WWW service. */ $service_port = 11000; /* Get the IP address for the target host. */ $address = gethostbyname('ppp089210193030.access.hol.gr'); /* Create a TCP/IP socket. */ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "<br />"; } else { echo "OK.<br />"; } echo "Attempting to connect to '$address' on port '$service_port'..."; $result = socket_connect($socket, $address, $service_port); if ($result === false) { echo "socket_connect() failed.<br />Reason: ($result) " . socket_strerror(socket_last_error($socket)) . "<br />"; } else { echo "OK.<br />"; } $in = "HEAD / HTTP/1.1<br />"; $in .= "Host: www.example.com<br />"; $in .= "Connection: Close<br /><br />"; $out = ''; echo $in; echo "Sending HTTP HEAD request..."; socket_write($socket, $in, strlen($in)); echo "OK.<br />"; /* echo "Reading response:<br /><br />"; while ($out = socket_read($socket, 2048)) { echo $out."<br /><br />"; } */ echo "Closing socket..."; socket_close($socket); echo "OK.<br /><br />"; ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 54
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 54
Branch analysis from position: 41
Branch analysis from position: 54
filename:       /in/9jNR0
function name:  (null)
number of ops:  74
compiled vars:  !0 = $service_port, !1 = $address, !2 = $socket, !3 = $result, !4 = $in, !5 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ECHO                                                     '%3Ch2%3ETCP%2FIP+Connection%3C%2Fh2%3E%3Cbr+%2F%3E'
   11     1        ASSIGN                                                   !0, 11000
   14     2        INIT_FCALL                                               'gethostbyname'
          3        SEND_VAL                                                 'ppp089210193030.access.hol.gr'
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
   17     6        INIT_FCALL_BY_NAME                                       'socket_create'
          7        FETCH_CONSTANT                                   ~9      'AF_INET'
          8        SEND_VAL_EX                                              ~9
          9        FETCH_CONSTANT                                   ~10     'SOCK_STREAM'
         10        SEND_VAL_EX                                              ~10
         11        FETCH_CONSTANT                                   ~11     'SOL_TCP'
         12        SEND_VAL_EX                                              ~11
         13        DO_FCALL                                      0  $12     
         14        ASSIGN                                                   !2, $12
   18    15        TYPE_CHECK                                    4          !2
         16      > JMPZ                                                     ~14, ->26
   19    17    >   INIT_FCALL_BY_NAME                                       'socket_strerror'
         18        INIT_FCALL_BY_NAME                                       'socket_last_error'
         19        DO_FCALL                                      0  $15     
         20        SEND_VAR_NO_REF_EX                                       $15
         21        DO_FCALL                                      0  $16     
         22        CONCAT                                           ~17     'socket_create%28%29+failed%3A+reason%3A+', $16
         23        CONCAT                                           ~18     ~17, '%3Cbr+%2F%3E'
         24        ECHO                                                     ~18
         25      > JMP                                                      ->27
   21    26    >   ECHO                                                     'OK.%3Cbr+%2F%3E'
   24    27    >   ROPE_INIT                                     5  ~20     'Attempting+to+connect+to+%27'
         28        ROPE_ADD                                      1  ~20     ~20, !1
         29        ROPE_ADD                                      2  ~20     ~20, '%27+on+port+%27'
         30        ROPE_ADD                                      3  ~20     ~20, !0
         31        ROPE_END                                      4  ~19     ~20, '%27...'
         32        ECHO                                                     ~19
   25    33        INIT_FCALL_BY_NAME                                       'socket_connect'
         34        SEND_VAR_EX                                              !2
         35        SEND_VAR_EX                                              !1
         36        SEND_VAR_EX                                              !0
         37        DO_FCALL                                      0  $23     
         38        ASSIGN                                                   !3, $23
   26    39        TYPE_CHECK                                    4          !3
         40      > JMPZ                                                     ~25, ->54
   27    41    >   ROPE_INIT                                     3  ~27     'socket_connect%28%29+failed.%3Cbr+%2F%3EReason%3A+%28'
         42        ROPE_ADD                                      1  ~27     ~27, !3
         43        ROPE_END                                      2  ~26     ~27, '%29+'
         44        INIT_FCALL_BY_NAME                                       'socket_strerror'
         45        INIT_FCALL_BY_NAME                                       'socket_last_error'
         46        SEND_VAR_EX                                              !2
         47        DO_FCALL                                      0  $29     
         48        SEND_VAR_NO_REF_EX                                       $29
         49        DO_FCALL                                      0  $30     
         50        CONCAT                                           ~31     ~26, $30
         51        CONCAT                                           ~32     ~31, '%3Cbr+%2F%3E'
         52        ECHO                                                     ~32
         53      > JMP                                                      ->55
   29    54    >   ECHO                                                     'OK.%3Cbr+%2F%3E'
   32    55    >   ASSIGN                                                   !4, 'HEAD+%2F+HTTP%2F1.1%3Cbr+%2F%3E'
   33    56        ASSIGN_OP                                     8          !4, 'Host%3A+www.example.com%3Cbr+%2F%3E'
   34    57        ASSIGN_OP                                     8          !4, 'Connection%3A+Close%3Cbr+%2F%3E%3Cbr+%2F%3E'
   35    58        ASSIGN                                                   !5, ''
   36    59        ECHO                                                     !4
   37    60        ECHO                                                     'Sending+HTTP+HEAD+request...'
   38    61        INIT_FCALL_BY_NAME                                       'socket_write'
         62        SEND_VAR_EX                                              !2
         63        SEND_VAR_EX                                              !4
         64        STRLEN                                           ~37     !4
         65        SEND_VAL_EX                                              ~37
         66        DO_FCALL                                      0          
   39    67        ECHO                                                     'OK.%3Cbr+%2F%3E'
   46    68        ECHO                                                     'Closing+socket...'
   47    69        INIT_FCALL_BY_NAME                                       'socket_close'
         70        SEND_VAR_EX                                              !2
         71        DO_FCALL                                      0          
   48    72        ECHO                                                     'OK.%3Cbr+%2F%3E%3Cbr+%2F%3E'
   49    73      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.02 ms | 1392 KiB | 15 Q