November 2001
Beginner
320 pages
5h 53m
English
Whether you are used to using the built-in Perl socket functions or the IO::Socket module, you shouldn't have any problems making the move to using Python's object based model. With Perl the first stage is to create a new generic socket using the socket function, we then use that as a base from which to bind to a service port in order to provide a network service, or to connect to a remote service. For example, the Perl fragment below creates a socket and then connects to a remote host:
use Socket; sub open_tcp_socket { my ($SOCKETHANDLE, $remotehost, $service_name) = @_; socket($SOCKETHANDLE,PF_INET,SOCK_STREAM,'tcp'); my $port_num = (getservbyname($service_name,'tcp'))[2]; my $remote_socket = sockaddr_in($port_num, scalar ...Read now
Unlock full access