libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] running libmicrohttpd on a particular interface


From: Christian Grothoff
Subject: Re: [libmicrohttpd] running libmicrohttpd on a particular interface
Date: Tue, 13 Apr 2010 15:52:48 +0200
User-agent: KMail/1.12.4 (Linux/2.6.32-trunk-vserver-amd64; KDE/4.3.4; x86_64; ; )

Yes, this is possible using:

  /**
   * Bind daemon to the supplied sockaddr. this option should be followed by a
   * 'struct sockaddr *'.  If 'MHD_USE_IPv6' is specified, the 'struct 
sockaddr*'
   * should point to a 'struct sockaddr_in6', otherwise to a 'struct 
sockaddr_in'.
   */
  MHD_OPTION_SOCK_ADDR = 6,


Just initialize your struct sockaddr with the proper address information (see 
for example, man 7 ipv6):

Address Format
           struct sockaddr_in6 {
               sa_family_t     sin6_family;   /* AF_INET6 */
               in_port_t       sin6_port;     /* port number */
               uint32_t        sin6_flowinfo; /* IPv6 flow information */
               struct in6_addr sin6_addr;     /* IPv6 address */
               uint32_t        sin6_scope_id; /* Scope ID (new in 2.4) */
           };

           struct in6_addr {
               unsigned char   s6_addr[16];   /* IPv6 address */
           };

       sin6_family is always set to AF_INET6; sin6_port is the protocol port 
(see sin_port in ip(7));  sin6_flowinfo  is  the  IPv6
       flow  identifier;  sin6_addr is the 128-bit IPv6 address.  sin6_scope_id 
is an ID depending on the scope of the address.  It
       is new in Linux 2.4.  Linux only supports it for link scope addresses, 
in that case  sin6_scope_id  contains  the  interface
       index (see netdevice(7))


So setting sin6_scope_id should do the trick.

Caveat: I've not actually tried this.

Best,

Christian


n Tuesday 13 April 2010 03:00:03 am K Q wrote:
> Hi,
> 
> In addition to specifying the port to listen to, is it possible to specify
>  an interface?
> 
> In particular, I would like to confine my software service to
>  localhost:<port>
> 
> Thanks,
> 
> Ken
> 
> _________________________________________________________________
> Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
> http://clk.atdmt.com/GBL/go/196390709/direct/01/
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]