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 />"; } if (socket_bind($sock, $address, $port) === false) { echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n"; }else { echo "bind 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 = 34, Position 2 = 44
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 72
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 73
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 59, Position 2 = 72
Branch analysis from position: 59
Branch analysis from position: 72
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 44
Branch analysis from position: 34
Branch analysis from position: 44
filename:       /in/1cafo
function name:  (null)
number of ops:  92
compiled vars:  !0 = $service_port, !1 = $address, !2 = $socket, !3 = $sock, !4 = $port, !5 = $result, !6 = $in, !7 = $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                                         $9      
          5        ASSIGN                                                   !1, $9
   17     6        INIT_FCALL_BY_NAME                                       'socket_create'
          7        FETCH_CONSTANT                                   ~11     'AF_INET'
          8        SEND_VAL_EX                                              ~11
          9        FETCH_CONSTANT                                   ~12     'SOCK_STREAM'
         10        SEND_VAL_EX                                              ~12
         11        FETCH_CONSTANT                                   ~13     'SOL_TCP'
         12        SEND_VAL_EX                                              ~13
         13        DO_FCALL                                      0  $14     
         14        ASSIGN                                                   !2, $14
   18    15        TYPE_CHECK                                    4          !2
         16      > JMPZ                                                     ~16, ->26
   19    17    >   INIT_FCALL_BY_NAME                                       'socket_strerror'
         18        INIT_FCALL_BY_NAME                                       'socket_last_error'
         19        DO_FCALL                                      0  $17     
         20        SEND_VAR_NO_REF_EX                                       $17
         21        DO_FCALL                                      0  $18     
         22        CONCAT                                           ~19     'socket_create%28%29+failed%3A+reason%3A+', $18
         23        CONCAT                                           ~20     ~19, '%3Cbr+%2F%3E'
         24        ECHO                                                     ~20
         25      > JMP                                                      ->27
   21    26    >   ECHO                                                     'OK.%3Cbr+%2F%3E'
   23    27    >   INIT_FCALL_BY_NAME                                       'socket_bind'
         28        SEND_VAR_EX                                              !3
         29        SEND_VAR_EX                                              !1
         30        SEND_VAR_EX                                              !4
         31        DO_FCALL                                      0  $21     
         32        TYPE_CHECK                                    4          $21
         33      > JMPZ                                                     ~22, ->44
   24    34    >   INIT_FCALL_BY_NAME                                       'socket_strerror'
         35        INIT_FCALL_BY_NAME                                       'socket_last_error'
         36        SEND_VAR_EX                                              !3
         37        DO_FCALL                                      0  $23     
         38        SEND_VAR_NO_REF_EX                                       $23
         39        DO_FCALL                                      0  $24     
         40        CONCAT                                           ~25     'socket_bind%28%29+failed%3A+reason%3A+', $24
         41        CONCAT                                           ~26     ~25, '%0A'
         42        ECHO                                                     ~26
         43      > JMP                                                      ->45
   26    44    >   ECHO                                                     'bind+OK.%3Cbr+%2F%3E'
   29    45    >   ROPE_INIT                                     5  ~28     'Attempting+to+connect+to+%27'
         46        ROPE_ADD                                      1  ~28     ~28, !1
         47        ROPE_ADD                                      2  ~28     ~28, '%27+on+port+%27'
         48        ROPE_ADD                                      3  ~28     ~28, !0
         49        ROPE_END                                      4  ~27     ~28, '%27...'
         50        ECHO                                                     ~27
   30    51        INIT_FCALL_BY_NAME                                       'socket_connect'
         52        SEND_VAR_EX                                              !2
         53        SEND_VAR_EX                                              !1
         54        SEND_VAR_EX                                              !0
         55        DO_FCALL                                      0  $31     
         56        ASSIGN                                                   !5, $31
   31    57        TYPE_CHECK                                    4          !5
         58      > JMPZ                                                     ~33, ->72
   32    59    >   ROPE_INIT                                     3  ~35     'socket_connect%28%29+failed.%3Cbr+%2F%3EReason%3A+%28'
         60        ROPE_ADD                                      1  ~35     ~35, !5
         61        ROPE_END                                      2  ~34     ~35, '%29+'
         62        INIT_FCALL_BY_NAME                                       'socket_strerror'
         63        INIT_FCALL_BY_NAME                                       'socket_last_error'
         64        SEND_VAR_EX                                              !2
         65        DO_FCALL                                      0  $37     
         66        SEND_VAR_NO_REF_EX                                       $37
         67        DO_FCALL                                      0  $38     
         68        CONCAT                                           ~39     ~34, $38
         69        CONCAT                                           ~40     ~39, '%3Cbr+%2F%3E'
         70        ECHO                                                     ~40
         71      > JMP                                                      ->73
   34    72    >   ECHO                                                     'OK.%3Cbr+%2F%3E'
   37    73    >   ASSIGN                                                   !6, 'HEAD+%2F+HTTP%2F1.1%3Cbr+%2F%3E'
   38    74        ASSIGN_OP                                     8          !6, 'Host%3A+www.example.com%3Cbr+%2F%3E'
   39    75        ASSIGN_OP                                     8          !6, 'Connection%3A+Close%3Cbr+%2F%3E%3Cbr+%2F%3E'
   40    76        ASSIGN                                                   !7, ''
   41    77        ECHO                                                     !6
   42    78        ECHO                                                     'Sending+HTTP+HEAD+request...'
   43    79        INIT_FCALL_BY_NAME                                       'socket_write'
         80        SEND_VAR_EX                                              !2
         81        SEND_VAR_EX                                              !6
         82        STRLEN                                           ~45     !6
         83        SEND_VAL_EX                                              ~45
         84        DO_FCALL                                      0          
   44    85        ECHO                                                     'OK.%3Cbr+%2F%3E'
   51    86        ECHO                                                     'Closing+socket...'
   52    87        INIT_FCALL_BY_NAME                                       'socket_close'
         88        SEND_VAR_EX                                              !2
         89        DO_FCALL                                      0          
   53    90        ECHO                                                     'OK.%3Cbr+%2F%3E%3Cbr+%2F%3E'
   54    91      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.07 ms | 1404 KiB | 15 Q