D
David Corbin
Why is TCPServer inheriting from TCPSocket? What methods on it might be used
other than accept, and close?
David
other than accept, and close?
David
Why is TCPServer inheriting from TCPSocket? What methods on it might
be used
other than accept, and close?
A TCP Server is just a socket you called listen(2) on:
To accept connections, a socket is first created with socket(2), a
will-
ingness to accept incoming connections and a queue limit for
incoming
connections are specified with listen(), and then the connections
are
accepted with accept(2). The listen() call applies only to
sockets of
type SOCK_STREAM or SOCK_SEQPACKET.
David Corbin said:Exactly my point. So why does it inherit from TCPSocket, and more importanly
IO? read, write and all the variations are all not applicable, as far as I
can tell.
Exactly my point. So why does it inherit from TCPSocket, and more importanly
IO? read, write and all the variations are all not applicable, as far as I
can tell.
Exactly because it is a TCPSocket. A TCPServer is a TCPSocket with
bound local address(es) (whether it is a specific local address or all
addresses the local host responds to) and thus can be made to listen
to incoming TCP connections on those _bound_ local address(es).
In data 3/29/2005 said:Is it really a TCPSocket, or is it just a TCP socket. If it's a TCPSocket, I
could do this.
socket = TCPServer('www.google.com', 80)
socket.puts "GET /"
etc. It's not that I think I can't do that (it might actually work for all I
know), but I can't imagine why I would to.
Is it really a TCPSocket, or is it just a TCP socket. If it's a
TCPSocket, I
could do this.
socket = TCPServer('www.google.com', 80)
socket.puts "GET /"
etc. It's not that I think I can't do that (it might actually work
for all I
know), but I can't imagine why I would to.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.