| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | package X11::Protocol::Connection::INETFH; | ||
| 4 | |||
| 5 | # Copyright (C) 1997 Stephen McCamant. All rights reserved. This program | ||
| 6 | # is free software; you can redistribute and/or modify it under the same | ||
| 7 | # terms as Perl itself. | ||
| 8 | |||
| 9 | use X11::Protocol::Connection::FileHandle; | ||
| 10 | use FileHandle; | ||
| 11 | use Socket; | ||
| 12 | use Carp; | ||
| 13 | use strict; | ||
| 14 | use vars qw($VERSION @ISA); | ||
| 15 | |||
| 16 | @ISA = ('X11::Protocol::Connection::FileHandle'); | ||
| 17 | |||
| 18 | $VERSION = 0.01; | ||
| 19 | |||
| 20 | sub open { | ||
| 21 | my($pkg) = shift; | ||
| 22 | my($host, $dispnum) = @_; | ||
| 23 | my($sock) = new FileHandle; | ||
| 24 | socket $sock, PF_INET(), SOCK_STREAM(), getprotobyname("tcp") | ||
| 25 | or croak "socket: $!"; | ||
| 26 | connect $sock, sockaddr_in(6000 + $dispnum, inet_aton $host) or | ||
| 27 | croak "Can't connect to display `$host:$dispnum': $!"; | ||
| 28 | $sock->autoflush(1); | ||
| 29 | return bless \$sock, $pkg; | ||
| 30 | } | ||
| 31 | 1; | ||
| 32 | __END__ |