network programming and sockets be to set up interprocess communication between processes created by os fork(for examplethe parent process would call socketpair(to create pair of sockets and call os fork(the parent and child processes would then communicate with each other using these sockets sockets are represented by an instance of type sockettype the following methods are available on socketss accept(accepts connection and returns pair (connaddress)where conn is new socket object that can be used to send and receive data on the connection and address is the address of the socket on the other end of the connection bind(addressbinds the socket to an address the format of address depends on the address family in most casesit' tuple of the form (hostnameportfor ip addressesthe empty string represents inaddr_any and the string 'represents inaddr_broadcast the inaddr_any host name (the empty stringis used to indicate that the server allows connections on any internet interface on the system this is often used when server is multihomed the inaddr_broadcast host name (''is used when socket is being used to send broadcast message close(closes the socket sockets are also closed when they're garbage-collected connect(addressconnects to remote socket at address the format of address depends on the address familybut it' normally tuple (hostnameportit raises socket error if an error occurs if you're connecting to server on the same computeryou can use the name 'localhostas hostname connect_ex(addresslike connect(address)but returns on success or the value of errno on failure fileno(returns the socket' file descriptor getpeername(returns the remote address to which the socket is connected usually the return value is tuple (ipaddrport)but this depends on the address family being used this is not supported on all systems getsockname(returns the socket' own address usually this is tuple (ipaddrports getsockopt(leveloptname [buflen]returns the value of socket option level defines the level of the option and is sol_socket for socket-level options or protocol number such as ipproto_ip for protocol-related options optname selects specific option if buflen is omittedan integer option is assumed and its integer value is returned if buflen is givenit specifies the maximum length of the buffer used to receive the option this buffer is lib fl ff