From: Dave Thomas Date: 2001-01-10T06:49:14+09:00 Subject: [ruby-talk:8960] Re: sockaddr Ernest Ellingson writes: > Does anyone know where I can find an example of building a sockaddr > structure and mapping it to an opaque binary string. I know I should be > using a higher level socket class but the server I'm talking to drops the > connection immediately after I do a puts on a TCPsocket. I want to do a > put on the socket and then remain connected, indefinitely for information > from the server. I've seen an example of this in Python and in Perl. It > looks like I have to create a new Socket object. The connect requires a > socaddr structure contained in a string. Have a look at ruby-talk:8634. Basically it looks like sock = Socket.open(Socket::AF_INET, Socket::SOCK_STREAM, 0) n = Socket.gethostname("localhost") sockaddr = [Socket::AF_INET, 3456, n[3], 0, 0].pack("snA4NN") sock.bind(sockaddr) Regards Dave