Menu

#1 notes on socket page

closed-fixed
None
5
2002-05-23
2002-03-06
No

I'm not sure if this is the correct way to give
feedback. The home page mentions sending mail but then
doesn't provide any email addresses.

I hope this formats ok... here goes:

notes on

http://cl-cookbook.sourceforge.net/sockets.html

re:
A socket is a two-way, reliable communication
stream between
two processes, usually (but not necessarily)
running on
different computers.

I don't know if 'port' supports these but another
important kind
of socket is the UDP socket which does not offer
'reliable' communcation.
You mention other kinds of sockets exist but you shouldn't
imply that all sockets offer reliable communcation.
UDP sockets are important if you want to talk to a DNS
server.

re:
A socket connection originates from a port on a
client machine,
and reaches another port on a server machine.

you're describing sockets in Internet address family.
Unix implementations
offer a Unix address family where sockets are named by
filenames.
These are important if you're communicating with local
sevices
on your Unix machine.

re:

Each hostname is associated with a unique IP address,
represented by four bytes.

you even mention below that this isn't true, that DNS
maps a hostname
to zero or more IP addresses.

re:
Ports are represented as integer numbers in the
range 0-65535

Actually 1-65535. Port 0 can't be allocated.

re:
There are two ways that things could go wrong at
this stage:
either your process does not have sufficient
privileges to
open the desired port (for example, you are
trying to open a
port below 1024 without being root under unix),
or the port you
have chosen has already been opened by another
process.
In both cases, Lisp will signal an error.

another common problem, especially when debugging, is
that you closed
a socket at that address less than 30 seconds ago and
are trying
to open a new socket at that address. The operating system
imposes a delay on reopening a socket at the same
address as
a previous socket. You can turn off this delay by
specifying
that you want the address to be reuseable. [I don't
know how
this is done in Port]

re:
* The specified port was not opened on the remote
machine. In this case OPEN-SOCKET returns immediately
with a "connection refused" error.
* The destination port was opened but the server
process did not call SOCKET-ACCEPT. In this case the
connection will be established, but no one will be
listening at the other end. This should never happen
when connecting to properly written servers.
* The destination port is open and the server
process is listening. In this case the connection is
established, and OPEN-SOCKET returns a "socket-stream"
structure.

This is a bit confused. The client can't tell if the
the server
is blocked waiting on a call to socket-accept, and
really doesn't care.
The operating system on the server machine accepts and
establishes
the connection as long as there is space in the backlog
queue for that socket.
When the server program gets around to calling
socket-accept
the call returns immediately if there is a connection
already
on the backlog queue, otherwise socket-accept blocks.
Thus the server program need not worry that if a connection
comes in it will be lost if the server is off doing
housekeeping work and not
sitting in a call to socket-accept.

Discussion

  • Edi Weitz

    Edi Weitz - 2002-04-10
    • assigned_to: nobody --> albertoriva
     
  • Alberto Riva

    Alberto Riva - 2002-05-23
    • status: open --> closed-fixed
     

Log in to post a comment.