Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

mongoose examples -> IPv6 not running

moatzemoatze Germany

Hi all,

I was trying to establish a tcp connection to an IPv6 webserver.
I tried the examples but things don't seem to work.

Ubuntu 16.04 32bit

mongoose.h

#define MG_ENABLE_IPV6 1
#define MG_ENABLE_DEBUG 1

Using code from simplest_web_server/ and http_client/

Both, server and client work fine with ipv4, with ipv6 I cannot establish connection.

Debug output from server doesnt give me much information back,
output from client:

mg_connect_opt             0x9cfbbc8 tcp://[::1]:8000 -,-,-
mg_do_connect              0x9cfbbc8 tcp://0.0.0.0:8000
mg_socket_if_connect  0x9cfbbc8 sock 5 rc -1 errno 97 err 97 

I was trying to use netcat or curl to establish connection to the mongoose server, this failed too:

curl -gv 6 "http://[::1]:8000
...
Trying ::1...
connect to ::1 port 8000 failed: Connection refused

Opening a listener via netcat and using netcat or curl to connect works fine.
Trying to use mongoose http_client results in same error as above.

Does anyone have hints what could be the problem?

Best regards!

Thanked by 1codewarrior71

Comments

  • moatzemoatze Germany

    I could get it running with following patch:

    in mg_socket_if_connect_tcp
    -- nc->sock = socket(AF_INET; SOCK_STREAM, proto);
    ...
    -- rc = connect(nc->sock, &sa->sa,(sizeof) sa->sa.sin);
    
    ++ socklen_t sa_len = (sa->sa.sa_family ==AF_INET) ? sizeof(sa->sin) : sizeof(sa->sin6);
    ++ nc->sock = socket(sa->sa.sa_family;SOCK_STREAM, proto);
    ...
    ++  rc = connect(nc->sock, &sa->sa, sa_len);
    
  • codewarrior71codewarrior71 Deutschland

    Great, now it works - thanks :)

Sign In or Register to comment.