NAME

IO::Socket - Socket filedescriptor class

SYNOPSIS

use IO::Socket;

$sock = IO::Socket->new(Peer	 => $host, 
			 Service => 'ftp', 
			);

$sock = IO::Socket->new(Listen  => 5,
			 Proto   => 'tcp'
			);

DESCRIPTION

IO::Socket is a class which simplifies the creating of a socket. With one function call it will do all the required lookups and system calls to create the required socket.

To create a socket connection to a foreign host ftp.uu.net using the ftp service

$sock = IO::Socket->new(Peer	 => $host, 
			 Service => 'ftp', 
			);

If you want to use the same protocal as the ftp service but provide your own port number to connect to

$sock = IO::Socket->new(Peer	 => $host, 
			 Service => 'ftp', 
			 Port    => 2001,
			);

new( %args )

The new constructor takes its arguments in the form of a hash. Accepted arguments are

Peer     => remote host name for a 'connect' socket
Proto    => specifiy protocol by it self (but override by Service)
Service  => require service eg 'ftp' or 'ftp/tcp', overrides Proto
Port     => port num for connect eg 'ftp' or 21, defaults to Service
Bind     => port to bind to, defaults to INADDR_ANY
Listen   => queue size for listen

autoflush( [$val] )

Set the file descriptor to autoflush, depending on $val

accept

perform the system call accept on the socket and return a new IO::Soscket object. This object can be used to communicate with the client that was trying to connect.

close

Close the file descriptor

dup

Create a duplicate of the socket object

sockname

Return a packed sockaddr structure for the socket

sockaddr

Return the address part of the sockaddr structure for the socket

sockport

Return the port number that the socket is using on the local host

sockhost

Return the address part of the sockaddr structure for the socket in a text form xx.xx.xx.xx

peername, peeraddr, peerport, peerhost

Same as for the sock* functions, but returns the data about the peer host instead of the local host.

send( $buf [, $flags [, $to]] )

For a udp socket, send the contents of $buf to the remote host $to using flags $flags.

If $to is not specified then the data is sent to the host which the socket last communicated with, ie sent to or recieved from.

If $flags is ommited then 0 is used

recv( $buf, $len [, $flags] )

Receive $len bytes of data from the socket and place into $buf

If $flags is ommited then 0 is used

AUTHOR

Graham Barr <Graham.Barr@tiuk.ti.com>

REVISION

$Revision: 1.1 $

COPYRIGHT

Copyright (c) 1995 Graham Barr. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.