dousui6488 2018-04-13 08:20 采纳率: 100%
浏览 5535
已采纳

怎么在Curl中指定传出端口?

亲爱的,我正在尝试从Apache Server执行php curl调用,但我需要指定特定端口(出站)的请求,或者至少知道Apache使用的输出端口的范围。因为目标服务器位于一个严格的防火墙后面,它只允许一个IP和一个特定端口通过。希望得到你的帮助。
  • 写回答

1条回答 默认 最新

  • dtjxhf595733 2018-04-13 08:29
    关注

    You could try this. i think this option CURLOPT_LOCALPORT is what you're looking for

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://example.com/");
    curl_setopt($ch, CURLOPT_PORT, [destinationport]);
    
    curl_setopt($ch, CURLOPT_LOCALPORT, [sourceport]);
    
    $output = curl_exec($ch);
    curl_close($ch);      
    print($output);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记