In data 3/29/2005, "David Corbin" <dcorbin@machturtle.com> ha scritto:
>On Monday 28 March 2005 11:11 am, Yohanes Santoso wrote:
>> David Corbin <dcorbin@machturtle.com> writes:
>> > 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.
>> >
>> > On Sunday 27 March 2005 08:15 pm, Eric Hodel wrote:
>> >> A TCP Server is just a socket you called listen(2) on:
>>
>> 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).
>
>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.
I don't understand what the deal is here. This is how standard
sockets work. A server is, literally, a socket that's listen()ing
for connections: its input consists of connection requests. In
addition to that, since it's a socket, a server must call socket()
to establish itself, just like a 'client' socket. Therefore it
makes sense for a TCPServer to be a TCPSocket (without it, one
would establish a server by calling TCPSocket#listen). Is this
separation of responsibility causing problems for you?
E