Telnet server (behind FW) that will call its client ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Telnet server (behind FW) that will call its client ?

Jump to solution
1,027 Views
robroz
Contributor III

Hi,

we intend to have MQX sistem with telnet server that will be behind Firewall. The only way we can reach its telnet server is that system establishes TCP connection and then somehow acts as telnet server on it. Telnet server is not obligatory, we only need remote shell access so maybe we can do this without telnet ?

I'm curious how to do this efficiently under MXQ... Can I establish TCP connection and then somehow leave it to telnet server to do the communication ?

Thanks in advance,

regards,

Bulek.

Labels (1)
Tags (2)
0 Kudos
1 Solution
739 Views
Martin_
NXP Employee
NXP Employee

Yes, for an active connection, you would use connect() function. For connect() function to succeed, a listening socket has to be in place on the remote host to accept the incoming connection. If connect() returns RTCS_OK, the application can use the socket to transfer data, send() and recv() functions in case of stream socket. So it can recv() whatever characters  via the socket, parse received characters and execute commands as needed by application.

You can pass an established socket into telnet server functionality in MQX - by using the socket from successful connect(). Function TELNETSRV_sockinit() starts the telnet server with an existing socket.

View solution in original post

0 Kudos
6 Replies
739 Views
Martin_
NXP Employee
NXP Employee

Hi Bulek,

check the /rtcs/examples/shell demo. There is the command "telnetd start" to start a telnet server task. It creates a listening socket on TCP port 23. You can connect a telnet client to it. Commands available via telnet shell are specified in const SHELL_COMMAND_STRUCT Telnetd_shell_commands[] in demo_cmd.c source file. In analogous way you can specify your own application specific commands.

0 Kudos
739 Views
robroz
Contributor III

Hi,

thanks for response. I'm trying to use telnet server in slightly different way. I'd like that Telnet server calls telne client and let him issue telnet commands. That's because telnet server is behind Firewall and this is the only way we can establish connection...

Thanks in advance,

regards,

Bulek.

0 Kudos
739 Views
Martin_
NXP Employee
NXP Employee

Hi Bulek,

With sockets, there is server/client concept. A server opens an unconnected socket in listening state, after that it responds to incoming connection request. A client connets to a remote listening socket.

Thus, if you need MQX to establish a stream socket connection actively, it needs to be a client (calls RTCS connect() API function). Remote peer needs to open a listening socket. There is also a telnet client in the /rtcs/examples/shell.

0 Kudos
739 Views
robroz
Contributor III

Hi,

thanks for response. I need to connect actively, cause server is behind firewall. My problem is that telnet server can probably be used only in real server way (listening for connections).

What I'd like to know is, if there is any chance to do this in more elegant way without rewritting custom telnet server from scratch. What I need is to first make connection and then simply pass working tcp connection to telnet server and say "from now on you're telnet server on this connection". Is this possible or what would be most elegant way to do this with MQX ?

Thanks  in advance,

regards,

Rob.

0 Kudos
740 Views
Martin_
NXP Employee
NXP Employee

Yes, for an active connection, you would use connect() function. For connect() function to succeed, a listening socket has to be in place on the remote host to accept the incoming connection. If connect() returns RTCS_OK, the application can use the socket to transfer data, send() and recv() functions in case of stream socket. So it can recv() whatever characters  via the socket, parse received characters and execute commands as needed by application.

You can pass an established socket into telnet server functionality in MQX - by using the socket from successful connect(). Function TELNETSRV_sockinit() starts the telnet server with an existing socket.

0 Kudos
739 Views
robroz
Contributor III

Thanks, this is exactly answer to my problem...

Regards,

Rob.

0 Kudos