curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Using A Different Socket For Requests

From: Gisle Vanem via curl-library <curl-library_at_cool.haxx.se>
Date: Wed, 22 Aug 2018 14:11:51 +0200

Isaiah Banks wrote:

> I'm sure this question has been asked before, but in doing some online research I have not found a good answer. What I'd
> like to do is create a custom socket for all curl requests to go through within a web application.
>
> I'm creating this socket within Python application but would like an app written in PHP to send request through it. I've
> tried creating it, binding it to a port, and then passing the port number to the cURL request using CURLOPT_LOCALPORT,
> but it didn't seem to work. Is this the only way to do it and still be able to monitor data packets? Or is there another
> recommended way?

W/o knowing any details or especially PHP, I assume you'll
need to call:
   setsockopt (sock, SOL_SOCKET, SO_REUSEADDR,..

before a bind() and before the socket can be shared like this.
Or use SO_EXCLUSIVEADDRUSE depending on you OS.

-- 
--gv
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2018-08-22