Logo Search packages:      
Sourcecode: r-cran-nws version File versions  Download package

def nwsclient::NwsServer::__init__ (   self,
  host = 'localhost',
  port = 8765 
)
Create a connection to the NWS server.

This constructor is only intended to be called internally.

Arguments:

host -- Host name of the NWS server.

port -- Port of the NWS server.

Definition at line 118 of file nwsclient.py.

                                                   :
        """Create a connection to the NWS server.

        This constructor is only intended to be called internally.

        Arguments:

        host -- Host name of the NWS server.

        port -- Port of the NWS server.

        """
        self.serverHost = host
        self.serverPort = port
        self.nwsSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        try:
            self.nwsSocket.connect((host, port))
        except socket.error:
            raise NwsConnectException, 'unable to connect to server at %s:%d' % (host, port)

        # denagle the socket to improve performance
        self.nwsSocket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

        # enable the keepalive option
        self.nwsSocket.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

        # try to set the 'close on exec' flag for the socket
        if fcntl and hasattr(fcntl, 'FD_CLOEXEC'):
            fd = self.nwsSocket.fileno()
            f = fcntl.fcntl(fd, fcntl.F_GETFD) | fcntl.FD_CLOEXEC
            fcntl.fcntl(fd, fcntl.F_SETFD, f)

        # handshaking that does nothing at the moment.
        self._sendAll('1111')
        self._recvN(4)


Generated by  Doxygen 1.6.0   Back to index