Package rospy :: Package impl :: Module tcpros_base :: Class TCPServer

Class TCPServer

source code

object --+
         |
        TCPServer

Simple server that accepts inbound TCP/IP connections and hands them off to a handler function. TCPServer obeys the ROS_IP/ROS_HOSTNAME environment variables

Instance Methods
 
__init__(self, inbound_handler, port=0)
Setup a server socket listening on the specified port.
source code
 
start(self)
Runs the run() loop in a separate thread
source code
 
run(self)
Main TCP receive loop.
source code
(str, int)
get_full_addr(self)
Returns: (ip address, port) of server socket binding
source code
 
shutdown(self)
shutdown I/O resources uses by this server
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, inbound_handler, port=0)
(Constructor)

source code 

Setup a server socket listening on the specified port. If the port is omitted, will choose any open port.

Parameters:
  • inbound_handler (fn(sock, addr)) - handler to invoke with new connection
  • port (int) - port to bind to, omit/0 to bind to any
Overrides: object.__init__

run(self)

source code 

Main TCP receive loop. Should be run in a separate thread -- use start() to do this automatically.

get_full_addr(self)

source code 
Returns: (str, int)
(ip address, port) of server socket binding