Click here to Skip to main content
15,902,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have mentioned the port number in the TelnetServer proc. It works well when I mention port number.
When I dont mention the port number like below, I see the traceback.

What I have tried:

I have mentioned the port number in the TelnetServer proc. It works well when I mention port number.
When I dont mention the port number like below, I see the traceback.

if __name__ == '__main__':

# Simple chat server to demonstrate connection handling via the
# async and telnet modules.

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('telnet_server')

# Create a telnet server with a port, address,
# a function to call with new connections
# and one to call with lost connections.

telnet_server = TelnetServer(
port='', ##### is there any way not to mention the port number here?
address='',
on_connect=on_connect,
on_disconnect=on_disconnect,
timeout = .05
)


Traceback (most recent call last):
File "/bootflash/telnet_server_1.py", line 173, in <module>
timeout = .05
File "/usr/lib/python2.7/site-packages/miniboa/async.py", line 80, in __init__
server_socket.bind((address, port))
File "/usr/lib64/python2.7/socket.py", line 224, in meth
TypeError: an integer is required
Posted
Updated 6-Apr-17 23:26pm
Comments
Rashmi Bhat 7-Apr-17 5:26am    
Setup is something link VM ---- Router (python script wth telnet server is run).
When I telnet from VM (default port is 23), which is natted to the port 7777 on thr router.
Here I dont understand why is the server getting into exception handler. I see from the packet capture port is translated to 7777.

DEBUG:root:Got three byte cmd 253:3
Traceback (most recent call last):
File "/xx/telnet_server_11.py", line 180, in <module>
telnet_server.poll() # Send, Recv, and look for new connections
File "/usr/lib/python2.7/site-packages/miniboa/async.py", line 179, in poll
self.clients[sock_fileno].socket_recv()
File "/usr/lib/python2.7/site-packages/miniboa/telnet.py", line 309, in socket_recv
self._iac_sniffer(byte)
File "/usr/lib/python2.7/site-packages/miniboa/telnet.py", line 385, in _iac_sniffer
self._three_byte_cmd(byte)
File "/usr/lib/python2.7/site-packages/miniboa/telnet.py", line 475, in _three_byte_cmd
self._note_local_option(option, True)
AttributeError: 'TelnetClient' object has no attribute '_note_local_option'

1 solution

Because the port number is the first parameter this can be only done when using the defaults for all parameters (using telnet_server = TelnetServer()).
Then port 7777 will be used according to miniboa 1.0.1 : Python Package Index[^]).

A server application must listen on a socket bound to a specific port and a client must specify the same port when he wants to connect. This is a fundamental principle of network connections.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900