Specify source ip using fsockopen

前端 未结 2 433
难免孤独
难免孤独 2020-12-20 22:27

On a server with multiple IPs routed to it, I\'d like to use PHP\'s fsockopen to open from a non-primary-interface ip (or a comparable method to be able to make fread and fw

2条回答
  •  一向
    一向 (楼主)
    2020-12-20 23:00

    This is not possible with fsockopen. You have to use the sockets wrapper:

    $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    socket_bind($sock, '192.168.1.100');
    socket_connect($sock, 'stackoverflow.com', 80);
    

提交回复
热议问题