hyln9 / ikarus

Optimizing incremental native-code compiler for R6RS scheme. This is a forked repository.
https://launchpad.net/ikarus
Other
5 stars 0 forks source link

tcp-connect fails under cygwin #268

Open hyln9 opened 10 years ago

hyln9 commented 10 years ago

Hi,

tcp-connect fails with the following under cygwin (XP):

Unhandled exception: Condition components:

  1. &assertion
  2. &who: tcp-connect
  3. &message: "failed to resolve host name or connect"
  4. &irritants: ("127.0.0.1" "1000")

I'm using the latest dev snapshot. I've used the 2 simple programs below for test. They work fine on my Linux box.

Thank you.

Cheers, Ugo

== Client code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs base) (rnrs bytevectors) (rnrs unicode) (rnrs io ports) (ikarus ipc) (rnrs syntax-case))

(define SERVER-HOST "127.0.0.1") (define SERVICE-PORT "1000")

(define SOH-CHAR #x01) (define VERSION-NUMBER #b1)

(define (client) (let-values ([(server->me me->server) (tcp-connect SERVER-HOST SERVICE-PORT)]) (display "writing to server") (newline) (put-u8 me->server 1) ; 'SOH' Character (put-u8 me->server 1) ; Version Number (put-bytevector me->server #vu8(00 00)) (put-bytevector me->server #vu8(00 05))

(close-output-port me->server)
(display "reading from server ...") (newline)
(let ([res-header (get-bytevector-n server->me 13)])
  (close-input-port server->me))))

(client)

== Server code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs bytevectors) (rnrs io ports) (ikarus ipc))

(define SERVICE-PORT 1000)

(define (server) (let ([listener (tcp-server-socket SERVICE-PORT)]) (let-values ([(client->me me->client) (accept-connection listener)]) (display (get-bytevector-n client->me 4)) (put-u8 me->client 111) (close-output-port me->client) (close-input-port client->me))))

(server)

Launchpad Details: #LP525050 Ugo - 2010-02-20 16:23:53 -0500

hyln9 commented 10 years ago

Disclaimer: I am no user of Cygwin.

Sorry to test you for stupid things... Unfortunately it seems there is no way to distinguish between a "failed to resolve" and a "failed to connect" error; are you sure that the server is already listening when the client connects? Does the following fail, too?

(import (rnrs) (ikarus))

(define SERVER-HOST "127.0.0.1") (define SERVICE-PORT "8080")

(fork (lambda (child-pid) (display "server started\n") (let ((listener (tcp-server-socket (string->number SERVICE-PORT)))) (display "server is listening\n") (let-values ([(client->me me->client) (accept-connection listener)]) (display "server accepted connection\n") (exit)))) (lambda () (display "client started\n") (nanosleep 2 0) (display "client is connecting...\n") (let-values ([(server->me me->server) (tcp-connect SERVER-HOST SERVICE-PORT)]) (display "client is connected\n") (exit))))

Launchpad Details: #LPC Marco Maggi - 2010-02-21 02:57:27 -0500

hyln9 commented 10 years ago

Thanks for the feedback, Marco.

The server is listening before the client starts.

Your code fails as well.

Cheers, Ugo

On Sun, Feb 21, 2010 at 8:57 AM, Marco Maggi

Disclaimer: I am no user of Cygwin.

Sorry to test you for stupid things... Unfortunately it seems there is no way to distinguish between a "failed to resolve" and a "failed to connect" error; are you sure that the server is already listening when the client connects? Does the following fail, too?

(import (rnrs) (ikarus))

(define SERVER-HOST "127.0.0.1") (define SERVICE-PORT "8080")

(fork (lambda (child-pid) (display "server started\n") (let ((listener (tcp-server-socket (string->number SERVICE-PORT)))) (display "server is listening\n") (let-values ([(client->me me->client) (accept-connection listener)]) (display "server accepted connection\n") (exit)))) (lambda () (display "client started\n") (nanosleep 2 0) (display "client is connecting...\n") (let-values ([(server->me me->server) (tcp-connect SERVER-HOST SERVICE-PORT)]) (display "client is connected\n") (exit))))

tcp-connect fails under cygwin https://bugs.launchpad.net/bugs/525050 You received this bug notification because you are a direct subscriber of the bug.

Status in Ikarus Scheme: New

Bug description: Hi,

tcp-connect fails with the following under cygwin (XP):

Unhandled exception: Condition components:

  1. &assertion
  2. &who: tcp-connect
  3. &message: "failed to resolve host name or connect"
  4. &irritants: ("127.0.0.1" "1000")

I'm using the latest dev snapshot. I've used the 2 simple programs below for test. They work fine on my Linux box.

Thank you.

Cheers, Ugo

== Client code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs base) (rnrs bytevectors) (rnrs unicode) (rnrs io ports) (ikarus ipc) (rnrs syntax-case))

(define SERVER-HOST "127.0.0.1") (define SERVICE-PORT "1000")

(define SOH-CHAR #x01) (define VERSION-NUMBER #b1)

(define (client) (let-values ([(server->me me->server) (tcp-connect SERVER-HOST SERVICE-PORT)]) (display "writing to server") (newline) (put-u8 me->server 1) ; 'SOH' Character (put-u8 me->server 1) ; Version Number (put-bytevector me->server #vu8(00 00)) (put-bytevector me->server #vu8(00 05))

(close-output-port me->server) (display "reading from server ...") (newline) (let ([res-header (get-bytevector-n server->me 13)]) (close-input-port server->me))))

(client)

== Server code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs bytevectors) (rnrs io ports) (ikarus ipc))

(define SERVICE-PORT 1000)

(define (server) (let ([listener (tcp-server-socket SERVICE-PORT)]) (let-values ([(client->me me->client) (accept-connection listener)]) (display (get-bytevector-n client->me 4)) (put-u8 me->client 111) (close-output-port me->client) (close-input-port client->me))))

(server)

To unsubscribe from this bug, go to: https://bugs.launchpad.net/ikarus/+bug/525050/+subscribe

Launchpad Details: #LPC Ugo - 2010-02-21 03:59:05 -0500

hyln9 commented 10 years ago

If you start the server and then in another process run:

(import (rnrs) (ikarus))

(display (foreign-call "ikrt_tcp_connect" (string->utf8 "127.0.0.1") (string->utf8 "8080"))) (newline)

what does it print? If it is positive: it is a file descriptor; if it is negative: it is an "errno" number codified as in "src/ikarus-errno.c".

Launchpad Details: #LPC Marco Maggi - 2010-02-21 07:27:45 -0500

hyln9 commented 10 years ago

Ciao Marco,

it just prints

f

Ugo

On Sun, Feb 21, 2010 at 1:27 PM, Marco Maggi

If you start the server and then in another process run:

(import (rnrs) (ikarus))

(display (foreign-call "ikrt_tcp_connect" (string->utf8 "127.0.0.1") (string->utf8 "8080"))) (newline)

what does it print? If it is positive: it is a file descriptor; if it is negative: it is an "errno" number codified as in "src/ikarus- errno.c".

tcp-connect fails under cygwin https://bugs.launchpad.net/bugs/525050 You received this bug notification because you are a direct subscriber of the bug.

Status in Ikarus Scheme: New

Bug description: Hi,

tcp-connect fails with the following under cygwin (XP):

Unhandled exception: Condition components:

  1. &assertion
  2. &who: tcp-connect
  3. &message: "failed to resolve host name or connect"
  4. &irritants: ("127.0.0.1" "1000")

I'm using the latest dev snapshot. I've used the 2 simple programs below for test. They work fine on my Linux box.

Thank you.

Cheers, Ugo

== Client code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs base) (rnrs bytevectors) (rnrs unicode) (rnrs io ports) (ikarus ipc) (rnrs syntax-case))

(define SERVER-HOST "127.0.0.1") (define SERVICE-PORT "1000")

(define SOH-CHAR #x01) (define VERSION-NUMBER #b1)

(define (client) (let-values ([(server->me me->server) (tcp-connect SERVER-HOST SERVICE-PORT)]) (display "writing to server") (newline) (put-u8 me->server 1) ; 'SOH' Character (put-u8 me->server 1) ; Version Number (put-bytevector me->server #vu8(00 00)) (put-bytevector me->server #vu8(00 05))

(close-output-port me->server) (display "reading from server ...") (newline) (let ([res-header (get-bytevector-n server->me 13)]) (close-input-port server->me))))

(client)

== Server code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs bytevectors) (rnrs io ports) (ikarus ipc))

(define SERVICE-PORT 1000)

(define (server) (let ([listener (tcp-server-socket SERVICE-PORT)]) (let-values ([(client->me me->client) (accept-connection listener)]) (display (get-bytevector-n client->me 4)) (put-u8 me->client 111) (close-output-port me->client) (close-input-port client->me))))

(server)

To unsubscribe from this bug, go to: https://bugs.launchpad.net/ikarus/+bug/525050/+subscribe

Launchpad Details: #LPC Ugo - 2010-02-21 12:54:07 -0500

hyln9 commented 10 years ago

If I am not mistaken, the problem should be the "getaddrinfo()" call in "do_connect()" file "ikarus-io.c"; the function is implemented in "ikarus-getaddrinfo.c". It appears the function is used on Cygwin, which does not come with a "getaddrinfo()", but it is not used on other systems.

Ugo, you may want to put some printf in there, and recompile Ikarus, to see what happens.

Launchpad Details: #LPC Marco Maggi - 2010-02-21 14:46:52 -0500

hyln9 commented 10 years ago

Current Cygwin versions do come with getaddrinfo. configure, indeed, reports getaddrinfo is available. Anyway, I did a test by recompiling Ikarus to include, and use, ikarus' implementation of getaddrinfo ("ikarus-getaddrinfo.c") but nothing changed. Any further suggestion?

Thanks.

Ciao, Ugo

On Sun, Feb 21, 2010 at 8:46 PM, Marco Maggi

If I am not mistaken, the problem should be the "getaddrinfo()" call in "do_connect()" file "ikarus-io.c"; the function is implemented in "ikarus-getaddrinfo.c". It appears the function is used on Cygwin, which does not come with a "getaddrinfo()", but it is not used on other systems.

Ugo, you may want to put some printf in there, and recompile Ikarus, to see what happens.

tcp-connect fails under cygwin https://bugs.launchpad.net/bugs/525050 You received this bug notification because you are a direct subscriber of the bug.

Status in Ikarus Scheme: New

Bug description: Hi,

tcp-connect fails with the following under cygwin (XP):

Unhandled exception: Condition components:

  1. &assertion
  2. &who: tcp-connect
  3. &message: "failed to resolve host name or connect"
  4. &irritants: ("127.0.0.1" "1000")

I'm using the latest dev snapshot. I've used the 2 simple programs below for test. They work fine on my Linux box.

Thank you.

Cheers, Ugo

== Client code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs base) (rnrs bytevectors) (rnrs unicode) (rnrs io ports) (ikarus ipc) (rnrs syntax-case))

(define SERVER-HOST "127.0.0.1") (define SERVICE-PORT "1000")

(define SOH-CHAR #x01) (define VERSION-NUMBER #b1)

(define (client) (let-values ([(server->me me->server) (tcp-connect SERVER-HOST SERVICE-PORT)]) (display "writing to server") (newline) (put-u8 me->server 1) ; 'SOH' Character (put-u8 me->server 1) ; Version Number (put-bytevector me->server #vu8(00 00)) (put-bytevector me->server #vu8(00 05))

(close-output-port me->server) (display "reading from server ...") (newline) (let ([res-header (get-bytevector-n server->me 13)]) (close-input-port server->me))))

(client)

== Server code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs bytevectors) (rnrs io ports) (ikarus ipc))

(define SERVICE-PORT 1000)

(define (server) (let ([listener (tcp-server-socket SERVICE-PORT)]) (let-values ([(client->me me->client) (accept-connection listener)]) (display (get-bytevector-n client->me 4)) (put-u8 me->client 111) (close-output-port me->client) (close-input-port client->me))))

(server)

To unsubscribe from this bug, go to: https://bugs.launchpad.net/ikarus/+bug/525050/+subscribe

Launchpad Details: #LPC Ugo - 2010-02-28 09:57:07 -0500

hyln9 commented 10 years ago

Ugo, try to change "do_connect()" in "src/ikarus-io.c" to the following (I only added the "fprintf()" call):

static ikptr do_connect(ikptr host, ikptr srvc, int sockettype){ struct addrinfo* info; int err = getaddrinfo((char)(long)(host+off_bytevectordata), (char)(long)(srvc+off_bytevector_data), 0, &info); if(err){ fprintf(stderr, "getaddrinfo: err=%d, %s\n", err, gai_strerror(err)); switch(err){ case EAI_SYSTEM: return ik_errno_to_code(); default: return false_object; } } ...

recompile and see what it prints. It assumes that the function "gai_strerror()" is implemented by Cygwin; if it is not just use:

fprintf(stderr, "getaddrinfo: err=%d\n", err);

and try to find the preprocessor symbol associated to the reported integer error code; on my Linux system they are the EAI codes in "netdb.h".

Marco Maggi

Launchpad Details: #LPC Marco Maggi - 2010-03-01 01:54:22 -0500

hyln9 commented 10 years ago

Ciao Marco,

that prints nothing -- getaddrinfo does get called but reporting no errors.

Thanks!

Ugo

On Mon, Mar 1, 2010 at 7:54 AM, Marco Maggi

Ugo, try to change "do_connect()" in "src/ikarus-io.c" to the following (I only added the "fprintf()" call):

static ikptr do_connect(ikptr host, ikptr srvc, int sockettype){ struct addrinfo* info; int err = getaddrinfo((char)(long)(host+off_bytevectordata), (char)(long)(srvc+off_bytevector_data), 0, &info); if(err){ fprintf(stderr, "getaddrinfo: err=%d, %s\n", err, gai_strerror(err)); switch(err){ case EAI_SYSTEM: return ik_errno_to_code(); default: return false_object; } } ...

recompile and see what it prints. It assumes that the function "gai_strerror()" is implemented by Cygwin; if it is not just use:

fprintf(stderr, "getaddrinfo: err=%d\n", err);

and try to find the preprocessor symbol associated to the reported integer

error code; on my Linux system they are the EAI codes in "netdb.h".

Marco Maggi

tcp-connect fails under cygwin https://bugs.launchpad.net/bugs/525050 You received this bug notification because you are a direct subscriber of the bug.

Status in Ikarus Scheme: New

Bug description: Hi,

tcp-connect fails with the following under cygwin (XP):

Unhandled exception: Condition components:

  1. &assertion
  2. &who: tcp-connect
  3. &message: "failed to resolve host name or connect"
  4. &irritants: ("127.0.0.1" "1000")

I'm using the latest dev snapshot. I've used the 2 simple programs below for test. They work fine on my Linux box.

Thank you.

Cheers, Ugo

== Client code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs base) (rnrs bytevectors) (rnrs unicode) (rnrs io ports) (ikarus ipc) (rnrs syntax-case))

(define SERVER-HOST "127.0.0.1") (define SERVICE-PORT "1000")

(define SOH-CHAR #x01) (define VERSION-NUMBER #b1)

(define (client) (let-values ([(server->me me->server) (tcp-connect SERVER-HOST SERVICE-PORT)]) (display "writing to server") (newline) (put-u8 me->server 1) ; 'SOH' Character (put-u8 me->server 1) ; Version Number (put-bytevector me->server #vu8(00 00)) (put-bytevector me->server #vu8(00 05))

(close-output-port me->server) (display "reading from server ...") (newline) (let ([res-header (get-bytevector-n server->me 13)]) (close-input-port server->me))))

(client)

== Server code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs bytevectors) (rnrs io ports) (ikarus ipc))

(define SERVICE-PORT 1000)

(define (server) (let ([listener (tcp-server-socket SERVICE-PORT)]) (let-values ([(client->me me->client) (accept-connection listener)]) (display (get-bytevector-n client->me 4)) (put-u8 me->client 111) (close-output-port me->client) (close-input-port client->me))))

(server)

To unsubscribe from this bug, go to: https://bugs.launchpad.net/ikarus/+bug/525050/+subscribe

Launchpad Details: #LPC Ugo - 2010-03-07 04:29:09 -0500

hyln9 commented 10 years ago

Sheesh! So the problem should be here, in "src/ikarus-io.c" function "do_connect()":

struct addrinfo* i = info; ikptr sock = false_object; /* this is the returned value */ while(i){ if(i->ai_socktype != socket_type){ i = i->ai_next; } else {

either "getaddrinfo()" returns with "info" set to NULL, or "ai_socket_type" is always different from "socket_type". To discover what happens we should try:

struct addrinfo* i = info; fprintf(stderr, "returned info pointer is %p\n", info); ikptr sock = false_object; while(i){ fprintf(stderr, "ai_socktype is %d, socket_type is %d\n", i->ai_socktype, socket_type); if(i->ai_socktype != socket_type){ i = i->ai_next; } else {

recompile and run.

Marco Maggi

Launchpad Details: #LPC Marco Maggi - 2010-03-07 06:14:56 -0500

hyln9 commented 10 years ago

Here is the output, Marco:

returned info pointer is 0x6e82e8 ai_socktype is 0, socket_type is 1

Ciao

On Sun, Mar 7, 2010 at 12:14 PM, Marco Maggi

Sheesh! So the problem should be here, in "src/ikarus-io.c" function "do_connect()":

struct addrinfo* i = info; ikptr sock = false_object; /* this is the returned value */ while(i){ if(i->ai_socktype != socket_type){ i = i->ai_next; } else {

either "getaddrinfo()" returns with "info" set to NULL, or "ai_socket_type" is always different from "socket_type". To discover what happens we should try:

struct addrinfo* i = info; fprintf(stderr, "returned info pointer is %p\n", info); ikptr sock = false_object; while(i){ fprintf(stderr, "ai_socktype is %d, socket_type is %d\n", i->ai_socktype, socket_type); if(i->ai_socktype != socket_type){ i = i->ai_next; } else {

recompile and run.

Marco Maggi

tcp-connect fails under cygwin https://bugs.launchpad.net/bugs/525050 You received this bug notification because you are a direct subscriber of the bug.

Status in Ikarus Scheme: New

Bug description: Hi,

tcp-connect fails with the following under cygwin (XP):

Unhandled exception: Condition components:

  1. &assertion
  2. &who: tcp-connect
  3. &message: "failed to resolve host name or connect"
  4. &irritants: ("127.0.0.1" "1000")

I'm using the latest dev snapshot. I've used the 2 simple programs below for test. They work fine on my Linux box.

Thank you.

Cheers, Ugo

== Client code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs base) (rnrs bytevectors) (rnrs unicode) (rnrs io ports) (ikarus ipc) (rnrs syntax-case))

(define SERVER-HOST "127.0.0.1") (define SERVICE-PORT "1000")

(define SOH-CHAR #x01) (define VERSION-NUMBER #b1)

(define (client) (let-values ([(server->me me->server) (tcp-connect SERVER-HOST SERVICE-PORT)]) (display "writing to server") (newline) (put-u8 me->server 1) ; 'SOH' Character (put-u8 me->server 1) ; Version Number (put-bytevector me->server #vu8(00 00)) (put-bytevector me->server #vu8(00 05))

(close-output-port me->server) (display "reading from server ...") (newline) (let ([res-header (get-bytevector-n server->me 13)]) (close-input-port server->me))))

(client)

== Server code ==

!/usr/bin/env scheme-script

(import (rnrs) (rnrs bytevectors) (rnrs io ports) (ikarus ipc))

(define SERVICE-PORT 1000)

(define (server) (let ([listener (tcp-server-socket SERVICE-PORT)]) (let-values ([(client->me me->client) (accept-connection listener)]) (display (get-bytevector-n client->me 4)) (put-u8 me->client 111) (close-output-port me->client) (close-input-port client->me))))

(server)

To unsubscribe from this bug, go to: https://bugs.launchpad.net/ikarus/+bug/525050/+subscribe

Launchpad Details: #LPC Ugo - 2010-03-07 11:19:42 -0500

hyln9 commented 10 years ago

(Marco, thanks for helping with this!)

Launchpad Details: #LPC Derick Eddington - 2010-03-07 17:18:16 -0500