1. Home
  2. Computing & Technology
  3. Python

Functions (Part 2)

By Al Lukaszewski, About.com

Functions

Here is documentation in-depth on the functions available through the socket module.

    gethostbyaddr(...)
        gethostbyaddr(host) -> (name, aliaslist, addresslist)
        Return the true host name, a list of aliases, and a list of IP addresses,
        for a host. The host argument is a string giving a host name or IP number.
    gethostbyname(...)
        gethostbyname(host) -> address
        Return the IP address (a string of the form '255.255.255.255') for a host.
    gethostbyname_ex(...)
        gethostbyname_ex(host) -> (name, aliaslist, addresslist)
        Return the true host name, a list of aliases, and a list of IP addresses,
        for a host. The host argument is a string giving a host name or IP number.
    gethostname(...)
        gethostname() -> string
        Return the current host name.
    getnameinfo(...)
        getnameinfo(sockaddr, flags) --> (host, port)
        Get host and port for a sockaddr.
    getprotobyname(...)
        getprotobyname(name) -> integer
        Return the protocol number for the named protocol. (Rarely used.)
    getservbyname(...)
        getservbyname(servicename[, protocolname]) -> integer
        Return a port number from a service name and protocol name.
        The optional protocol name, if given, should be 'tcp' or 'udp',
        otherwise any protocol will match.
    getservbyport(...)
        getservbyport(port[, protocolname]) -> string
        Return the service name from a port number and protocol name.
        The optional protocol name, if given, should be 'tcp' or 'udp',
        otherwise any protocol will match.
    getservbyport(...)
        getservbyport(port[, protocolname]) -> string
        Return the service name from a port number and protocol name.
        The optional protocol name, if given, should be 'tcp' or 'udp',
        otherwise any protocol will match.

Explore Python

More from About.com

  1. Home
  2. Computing & Technology
  3. Python
  4. Networking
  5. Python Network Programming : Python's socket Module - Part 3

©2008 About.com, a part of The New York Times Company.

All rights reserved.