Network Programming with Perl Directory UMM

Network Programming With Perl Directory Umm-Free PDF

  • Date:31 May 2020
  • Views:51
  • Downloads:0
  • Pages:79
  • Size:301.02 KB

Share Pdf : Network Programming With Perl Directory Umm

Download and Preview : Network Programming With Perl Directory Umm


Report CopyRight/DMCA Form For : Network Programming With Perl Directory Umm


Transcription:

Programming,Graham Barr,gbarr pobox com,Introduction Find information about. Properties of a socket,The socket model,Types of server. TCP server client,Common problems,examples Commonly used. network protocols,UDP server client,Case studies,IO Socket with. Introduction, Perl provides direct access to the C library routines for.
socket communication Often arguments and return, values are constants defined in the C header files or. are data structures which Perl will pass in a packed. binary format, The Socket module provides these constants and also. many functions for packing and unpacking these data. structures, The IO Socket module provides a higher level access. to creating a socket, CPAN contains many modules that provide a very high. level access to specific application protocols e g. Net FTP Net SMTP Net DNS etc,Socket properties,A generic socket has three properties.
An address family,A communication protocol,Socket types. There are many types of socket these include,Stream Connection oriented transport. Datagram Connection less transport, Raw Often used to talk directly to the IP layer For. example ping uses a raw socket to send ICMP, The system socket functions use numbers to represent. these The Socket module exports constants for these. use Socket qw SOCK STREAM SOCK DGRAM SOCK RAW,Address families.
Available address families include,AF UNIX Communication is limited to a single. machine Sometimes called AF LOCAL or AF FILE,The address is a filesystem path on the local. AF INET This address family uses the IP protocol,to communicate with other machines over a network. The address is 193 168 1 200 21,Others include AF APPLETALK AF IPX. These are represented as numbers and the Socket,module exports constants for these.
use Socket qw AF UNIX AF INET AF APPLETALK,Communication protocols. There are two protocols that are mainly used,TCP is used with a stream socket to provide a. reliable sequenced flow controlled channel of,communication. UDP is used with a datagram socket and delivers,datagrams to other endpoints Message boundaries. are preserved but sequence is not and delivery is,not guaranteed.
Protocols are represented as numbers but are not, available as constants Perl provides some functions for. translating protocol names to numbers and visa versa. number getprotobyname tcp,name getprotobynumber 6,The socket model. The Server,Creates a generic socket withsocket,Binds to a known address with bind. Tell system to watch for incoming connections with. Waits for a connection with accept or select,The socket model cont. The client,Creates generic socket withsocket,Binds to an address with bind.
Connects to server with connect using the known,address This establishes the connection. The socket model cont,The server is notified of the new connection. Either accept returns or select will report the,socket as readable. Server and Client communicate,Server and Client close the socket to break the. connection,Creating a socket,To create a socket you need to know all three.
properties about the socket,import required constants from the Socket module. use Socket qw AF INET SOCK STREAM,Obtain the value for the protocol. proto getprotobyname tcp,Create the socket,socket SOCK AF INET SOCK STREAM proto. die socket,Binding the socket, bind takes two arguments the first is the socket and. the second is a packed address, The Socket module provides functions for packing and.
unpacking addresses, sockaddr in allows you to either pack or unpack an. AF INET socket address In a scalar context it packs. and in a list context it will unpack,paddr sockaddr in port inaddr. port inaddr sockaddr in paddr, If the use of context here disturbs you then you can. explicitly call pack sockaddr in and,unpack sockaddr in. Binding the socket cont, Many protocols for example FTP and Telnet use well.
known port numbers But like communication protocols. these are not provided by constants but by lookup,port getservbyname ftp tcp. service getservbyport 21 tcp,name aliases port proto. getservbyname ftp tcp,name aliases port proto,getservbyport 21 tcp. If you do not care which port the socket is bound to you. can use 0 and the kernel will select a free port number. Binding the socket cont,Besides the port sockaddr in also needs an IP. If you do not want to bind the socket to a particular. interface the you can use INADDR ANY, If you want to bind the socket to a particular interface.
then you must pass a packed IP address,The Socket module provides inet aton and. inet ntoa to pack and unpack IP addresses,ipaddr inet aton localhost. quad inet ntoa ipaddr, Not calling bind is treated the same as calling bind. with a port of 0 and INADDR ANY This is not normally. Network Programming with Perl Graham Barr lt gbarr pobox com gt Slide 2 Agenda Introduction Properties of a socket The socket model TCP server client examples Using UDP UDP server client examples IO Socket with examples Find information about a socket Types of server Common problems Commonly used network protocols Case studies Slide 3

Related Books