1. Home
  2. Computing & Technology
  3. Python

Classes: socket (Part 3)

By Al Lukaszewski, About.com

    socket = class _socketobject(__builtin__.object)
        Methods defined here:
        getpeername(self, *args)
            getpeername() -> address info
            
            Return the address of the remote endpoint. For IP sockets, the address
            info is a pair (hostaddr, port).
        getsockname(self, *args)
            getsockname() -> address info
            
            Return the address of the local endpoint. For IP sockets, the address
            info is a pair (hostaddr, port).
        getsockopt(self, *args)
            getsockopt(level, option[, buffersize]) -> value
            
            Get a socket option. See the Unix manual for level and option.
            If a nonzero buffersize argument is given, the return value is a
            string of that length; otherwise it is an integer.
        gettimeout(self, *args)
            gettimeout() -> timeout
            
            Returns the timeout in floating seconds associated with socket
            operations. A timeout of None indicates that timeouts on socket
            operations are disabled.
        listen(self, *args)
            listen(backlog)
            
            Enable a server to accept connections. The backlog argument must be at
            least 1; it specifies the number of unaccepted connection that the system
            will allow before refusing new connections.
        makefile(self, mode='r', bufsize=-1)
            makefile([mode[, bufsize]]) -> file object
            
            Return a regular file object corresponding to the socket. The mode
            and bufsize arguments are as for the built-in open() function.
        sendall(self, *args)
            sendall(data[, flags])
            
            Send a data string to the socket. For the optional flags
            argument, see the Unix manual. This calls send() repeatedly
            until all data is sent. If an error occurs, it's impossible
            to tell how much data has been sent.
        setblocking(self, *args)

Explore Python

More from About.com

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

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

All rights reserved.