0 votes
by (630 points)

I have a client and server.
The server supports SFTP, TFTP, Modbus.
The client knows the IP address and port number of server to connect.

Now, the client needs to know if server is available or lost.
Can you kindly help me know which of the Rebex library can be used and how?

1 Answer

0 votes
by (144k points)

SFTP runs over SSH. To determine whether a server is listening at a particular port, just try connecting it using System.Net.Sockets.Socket class and receive the identification string.
If you would like to determine that an SSH server is really up and running, you can use Rebex Sftp, Ssh or SshSession class to connect to the server and negotiate an SSH session. If this works, the server is up and running. If it doesn't, there is an issue and you can use SftpException's or SshExceptions's Status property to determine what's going on. However, this of course doesn't really determine whether the SFTP subsystem for a particular user would work. The only reasonable way to determine that would be to authenticate as well and try establishing an SFTP channel (in other words, to call Sftp's Connect method followed by Login method).

TFTP is a very old and very simple file transfer protocol that runs over UDP. To determine if it's running, hopefully you could send a request and wait for proper response according to the protocol. However, we currently don't provide any TFTP library and are not familiar with the protocol, so this is outside the scope of our support.

As for Modbus - if you use Modbus over SSH, what I wrote about SFTP would apply as well. Otherwise, to determine whether a Modbus over TCP is availalbe, again try connecting to it using System.Net.Sockets.Socket.

...