diff --git a/moo/configure.ac b/moo/configure.ac index 49bb9d5..f833dda 100644 --- a/moo/configure.ac +++ b/moo/configure.ac @@ -189,6 +189,48 @@ LIBS="$save_LIBS" AC_SUBST(TERMINAL_LIBS) +dnl OLDLIBS="$LIBS" +dnl AC_SEARCH_LIBS([connect], [socket]) +dnl LIBS="$OLDLIBS" +dnl if test "$ac_cv_search_connect" != "none required" -a "$ac_cv_search_connect" != "no" +dnl then +dnl SOCKET_LIBS="$SOCKET_LIBS -lsocket" +dnl fi +dnl AC_SUBST(SOCKET_LIBS) +AC_CHECK_FUNCS([connect gethostbyname]) +if test "x$ac_cv_func_gethostbyname" = "xno" +then + AC_CHECK_LIB([nsl], [gethostbyname], [ + SOCKET_LIBS="$SOCKET_LIBS -lnsl" + AC_DEFINE(HAVE_GETHOSTBYNAME, 1) + ]) +fi +if test "x$ac_cv_func_connect" = "xno" +then + AC_CHECK_LIB([socket], [connect], [ + SOCKET_LIBS="$SOCKET_LIBS -lsocket" + AC_DEFINE(HAVE_CONNECT, 1) + ]) + + if test "x$ac_cv_lib_socket_connect" = xno + then + AC_CHECK_FUNCS([t_connect]) + if test "x$ac_cv_func_t_connect" = "xno" + then + AC_CHECK_LIB([nsl_s], [t_connect], [ + SOCKET_LIBS="$SOCKET_LIBS -lnsl_s" + AC_DEFINE(HAVE_T_CONNECT, 1) + ]) + fi + fi +fi +if test "x${platform_win32}" = "xyes" +then + SOCKET_LIBS="$SOCKET_LIBS -lws2_32" +fi +AC_SUBST(SOCKET_LIBS) + + dnl check is the import library for unicows.dll exists dnl this check doesn't look for a particular symbol dnl but for the symbol 'main' since i want to check diff --git a/moo/kernel/Socket.moo b/moo/kernel/Socket.moo index 74f12ce..604215a 100644 --- a/moo/kernel/Socket.moo +++ b/moo/kernel/Socket.moo @@ -505,7 +505,7 @@ error -> exception [ s := Socket domain: Socket.Domain.INET type: Socket.Type.STREAM. s inputAction: inact; outputAction: outact. - s connectTo: (SocketAddress fromString: '127.0.0.1:9999') do: conact. + s connectTo: (SocketAddress fromString: '192.168.1.108:9999') do: conact. s2 := Socket domain: Socket.Domain.INET type: Socket.Type.STREAM. s2 inputAction: accact. diff --git a/moo/mod/_sck.h b/moo/mod/_sck.h index 6d6dafb..1428e48 100644 --- a/moo/mod/_sck.h +++ b/moo/mod/_sck.h @@ -103,9 +103,9 @@ struct sck_t #endif #else # undef MOO_SIZEOF_SA_FAMILY_T -# define MOO_SIZEOF_SA_FAMILY_T MOO_SIZEOF_INT -# define MOO_SA_FAMILY_T_IS_SIGNED - typedef int sck_addr_family_t; +# define MOO_SIZEOF_SA_FAMILY_T MOO_SIZEOF_SHORT +# undef MOO_SA_FAMILY_T_IS_SIGNED + typedef unsigned short int sck_addr_family_t; #endif struct sck_addr_t diff --git a/moo/mod/sck.c b/moo/mod/sck.c index e9d236a..531aa58 100644 --- a/moo/mod/sck.c +++ b/moo/mod/sck.c @@ -63,6 +63,7 @@ static moo_pfrc_t pf_open_socket (moo_t* moo, moo_ooi_t nargs) typev |= SOCK_NONBLOCK | SOCK_CLOEXEC; create_socket: #endif + fd = socket (MOO_OOP_TO_SMOOI(dom), typev, MOO_OOP_TO_SMOOI(proto)); if (fd == -1) { @@ -324,7 +325,7 @@ static moo_pfrc_t pf_connect (moo_t* moo, moo_ooi_t nargs) n = connect(fd, (struct sockaddr*)MOO_OBJ_GET_BYTE_SLOT(arg), moo_sck_addr_len((sck_addr_t*)MOO_OBJ_GET_BYTE_SLOT(arg))); } while (n == -1 && errno == EINTR); - + if (n == -1 && errno != EINPROGRESS) { moo_seterrwithsyserr (moo, errno);