Commit graph

101 commits

Author SHA1 Message Date
Daniel Kochmański
e49eafac22 cmpc: get rid of another undocumented feature from FFI:C-INLINE
ffi:c-inline allowed for the xyntax @object (similar to the previous commit),
although only syntax "@(return x) = xxx" is specified in the documentation.
2023-09-25 14:35:14 +02:00
Michał "phoe" Herda
bb40da9fa6 Fix GET-PROTOCOL-BY-NAME with unknown protocols
The function SB-BSD-SOCKETS:GET-PROTOCOL-BY-NAME did not signal
an error when it was unable to find a protocol. This is fixed now
and an error of type UNKNOWN-PROTOCOL, with an accessor named
UNKNOWN-PROTOCOL-NAME, is being signaled. These two names are also
exported from the package SB-BSD-SOCKETS.

A test case is added.

Several other test cases are fixed with regard to :NO-ERROR clauses
inside HANDLER-CASEs.
2020-11-13 19:43:33 +01:00
Marius Gerbershagen
beadd585ce sockets: don't return the same address multiple times in get-host-by-name 2020-04-19 10:46:03 +02:00
Marius Gerbershagen
5451f73bb8 sockets: don't call getaddrinfo with AI_ADDRCONFIG
On linux, using AI_ADDRCONFIG causes getaddrinfo to return no ip
address for localhost when only the loopback connection is
active. Also, we only get ipv4 addresses anyway due to specifying
ai_family = AF_INET, therefore the AI_ADDRCONFIG flag in not necessary
anyway.
2020-04-19 10:46:03 +02:00
Marius Gerbershagen
12cac13786 sockets: fix GET-HOST-BY-NAME and GET-HOST-BY-ADDRESS
After the recent refactor of GET-HOST-BY-NAME to use getaddrinfo,
these functions had multiple problems that are fixed in this commit:
- in GET-HOST-BY-NAME, freeaddrinfo was called on an unitialized
  struct addrinfo if getaddrinfo failed
- error handling in GET-HOST-BY-NAME wasn't working, we were still
  trying to use the error handling for gethostbyname
- GET-HOST-BY-ADDRESS still used the deprecated gethostbyaddr function
2020-01-25 17:43:30 +01:00
Daniel Kochmański
ef450d9070 contrib: sockets: fix get-host-by-name
Remove flag AI_V4MAPPED which takes effect only for AF_INET6
family. Currently we do not work at all with ipv6, hence this flag is
a no-op. Moreover Android has no definition for this flag. See !172.

Fix contributed by Polos Ruetz. Closes !172.
2019-12-30 10:39:13 +01:00
Marius Gerbershagen
234a1084d5 contrib: sockets: fix mingw build 2019-12-08 00:22:52 +01:00
Marius Gerbershagen
b94c2f5fe6 contrib: sockets: add missing include
Needed by gai_strerror. Fixes #533.
2019-12-07 21:47:10 +01:00
Daniel Kochmański
de073ef274 sockets: recvfrom: cast sockaddr_in* to sockaddr* explicitly
Apparently CXX compiler needs this. Steps to reproduce the issue:

    ./configure --with-cxx && make

With this fix the problem is gone.
2019-11-25 15:40:28 +01:00
thijs
5747fddee9 contrib: get-host-by-name: use getaddrinfo instead of gethostbyname
- this improvement was suggested before in the comment
- fix print-object for descriptors which are not bound
2019-11-22 08:28:25 +01:00
Marius Gerbershagen
a08f26cc27 Merge branch 'fix-socket-receive-to-return-remote-addr' of https://gitlab.com/thijso/ecl into develop 2019-09-02 21:52:13 +02:00
thijs
98afe7cbd0 Fix socket-receive to match the documentation; return the address of the peer that sent a message 2019-08-31 16:28:16 +02:00
thijs
87a2076384 Fix socket-receive to match the documentation; set MSG_TRUNC when socket type is :datagram 2019-08-31 16:20:28 +02:00
Marius Gerbershagen
0b6311b399 contrib: remove use of legacy names 2019-01-14 21:29:34 +01:00
Daniel Kochmanski
c771b46c5f feature: export make-stream-from-fd interface 2017-10-11 10:25:59 +02:00
Daniel Kochmanski
54f7f9c424 sb-bsd-sockets: socket-receive: add default element-type 2017-09-30 11:12:00 +02:00
Kris Katterjohn
de661f580a Add ABORT keyword argument to SB-BSD-SOCKETS:SOCKET-CLOSE
This keyword argument was added in SBCL in 2010 and is used to pass
ABORT to CL:CLOSE.

The absence of this would obviously cause errors when code expects
this to be available.  For example, this happens in usocket's
SOCKET-CONNECT and would cause several errors in their test suite
with obscure error messages like

  Wrong number of arguments passed to function #<compiled-function 0000000003562e80>.

This is untested on Windows.
2017-02-11 19:18:50 -06:00
Daniel Kochmański
e640ef1c2b haiku: define ESOCKTNOSUPPORT to ENOTSUP
Haiku lacks some parts of POSIX API. Workaround to make sockets work.
2016-09-06 21:55:56 +02:00
Fabrizio Fabbri
52de2ceea6 Fix compilation for AIX and xlc compiler. 2016-03-02 12:08:48 -05:00
Eric Timmons
6eede933dd Add defaults for NETDB_{INTERNAL,SUCESS}.
NETDB_INTERNAL and NETDB_SUCCESS are not defined by POSIX, so some
libc implementations (such as musl) do not have them. When compiling
sockets contrib, check if these are defined and, if not, define them to
be zero.
2016-02-24 21:48:57 -05:00
Daniel Kochmański
7feed6c6f4 contrib: call provide uniformly
Various contrib modules called provide with varying syntax from "module"
through 'module to '#:module. The last one is picked:

(provide '#:module)
2015-10-23 18:18:58 +02:00
Daniel Kochmański
58ee224fe3 cosmetic: replace push' with pushnew'
When appending :wsock to *features*.
2015-10-23 18:16:50 +02:00
Sylvain Ageneau
5b0a9fe6c5 mobile: fix socket implementation on android
getprotobyname is not implemented in bionic libc.
2015-10-23 18:12:54 +02:00
Zack Piper
00521d869a Untabify everything. 2015-09-01 20:10:10 +00:00
Arto Bendiken
fa48714dd8 Fixed a NUL-termination bug in SOCKET-BIND and SOCKET-CONNECT.
The backslash in '\0' got lost on the way to the generated C file
(build/ext/sockets.c). There may be more of these issues elsewhere
in the code base.

This resolves CIDs 66405 and 66413 (Buffer not null terminated).
2014-10-14 21:39:58 +00:00
Philipp Marek
50ba000738 getprotobyname() may return NULL, causing segfaults in this function. 2014-02-22 11:00:53 +01:00
Juanjo Garcia-Ripoll
434c753e78 sockets.lisp defined MSG_WAITALL in an incompatible manner for cygwin (which now supports this flag) 2013-10-06 17:01:06 +02:00
Juan Jose Garcia Ripoll
5f4c7eee93 Coercions needed to compile on Windows with C++ compiler. 2012-08-25 00:24:46 +02:00
Juan Jose Garcia Ripoll
146b06794c Update the name of the stream mode constants in sockets.lisp 2012-07-08 21:19:11 +02:00
Juan Jose Garcia Ripoll
825fc8cbd3 Cnil and Ct are now part of legacy 2012-06-30 23:01:40 +02:00
Juan Jose Garcia Ripoll
a2c88a372b SOCKET-ACCEPT should return the port as a third value (M. Mondor) 2011-07-31 09:43:35 +02:00
Juan Jose Garcia Ripoll
5918c54f23 Fixed documentation and error string typos (P. Van Eynde) 2011-03-05 15:11:49 +01:00
Juan Jose Garcia Ripoll
02241f886a In sockets.lisp, the stream element type was overriden by a character-mode stream flag. 2011-01-26 14:34:39 +01:00
Juan Jose Garcia Ripoll
e6d180e7df The socket functions now accept an optional :ELEMENT-TYPE keyword argument, in addition to :EXTERNAL-FORMAT 2011-01-24 23:03:14 +01:00
Juan Jose Garcia Ripoll
c591f61d3e The nosignal argument to SOCKET-SEND works now also in BSD systems 2010-10-17 16:50:11 +02:00
Juan Jose Garcia Ripoll
747fddfecf Fixed typo in assertion 2010-05-27 20:05:07 +02:00
Juan Jose Garcia Ripoll
dacffdc468 SERVE-EVENT now allows streams and sockets as arguments, instead of file descriptors. 2010-02-22 15:11:41 +01:00
Juan Jose Garcia Ripoll
d8e828bf35 :EXTERNAL-FORMAT did not work on bi-directional sockets. 2010-02-19 00:22:19 +01:00
Juan Jose Garcia Ripoll
cce95aa087 Missing arguments in function call 2010-02-17 23:55:43 +01:00
Juan Jose Garcia Ripoll
f3fa64c038 Missing argument in call to socket-make-stream-inner. 2010-02-17 22:41:08 +01:00
Juan Jose Garcia Ripoll
3f341b28dd Fix SOCKET-MAKE-STREAM so that it works in Windows. 2010-02-17 20:49:49 +01:00
Juan Jose Garcia Ripoll
1941458e0d In SOCKETS, the stream is created as a two-way stream that automatically closes its components. We also make sure that the file descriptor is duplicated when using both input and output channels and implement new options :INPUT, :OUTPUT and :EXTERNAL-FORMAT for SOCKET-MAKE-STREAM. 2010-02-17 14:49:41 +01:00
Juan Jose Garcia Ripoll
113dd3c2ef When using threads and sockets, the stream is a two-way streams and its components must be closed separately. 2010-02-13 15:35:42 +01:00
Juan Jose Garcia Ripoll
dd4d8e036f Socket streams are now two-way streams. 2010-02-12 18:33:04 +01:00
Juan Jose Garcia Ripoll
b606466993 contrib/sockets/sockets.lisp: Implemente SO_LINGER properly (needs struct linger) (M. Mondor). In Windows, set-sockopt-timeval had the older interface, without the socket level. 2009-10-18 18:51:14 +02:00
Juan Jose Garcia Ripoll
25e7849e2b contrib/sockets/sockets.lisp: two more typos fixed (Chun Tian) 2009-10-17 21:41:51 +02:00
Juan Jose Garcia Ripoll
7d0e542de1 contrib/sockets/sockets.lisp: added a new argument to define-sockopt specifying the level of the interface (SOL_SOCKET or IPPROTO_TCP). 2009-10-17 19:55:35 +02:00
Juanjo
25c9b636e1 contrib/sockets/sockets.lisp: remove unused conditionalization. 2009-10-05 11:00:32 +02:00
Juan Jose Garcia Ripoll
61b7c0ac31 Same reverse fix as before. 2009-08-17 21:25:20 +02:00
Juan Jose Garcia Ripoll
7077608d93 Default buffering mode defaults to NIL (:NONE) so that we do not break code expecting no buffering. Change will be undone at some point in the future. 2009-08-17 20:30:35 +02:00