Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!
I have a little problem programming sockets, with C#.

But first.. I wrote a client-server application:
Server - in C++. Simple console server, on the same computer, which response every time, when it gets something.. on port 5200.

Client - in C#. Like that:
(Connect, send, receive and close connection)

_serverHost = IPAddress.Parse("127.0.0.1");
_hostEndPoint = new IPEndPoint(_serverHost, 5200);

_serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
_serverSocket.Connect(_hostEndPoint);

byte[] dataSend = CreateStartFrame(); 
_serverSocket.Send(dataSend);         

byte[] dataRecv = new byte[RECV_BUF_SIZE];         
int receivedDataLength = _serverSocket.Receive(dataRecv);   

_serverSocket.Shutdown(SocketShutdown.Both); 
_serverSocket.Close(); 


And that application - works.

Now, I want to something similar, but - on the external server with SSH on port 22.
What I;m doing now is: I use the same code, but with port 22, and host (my external host ip).

And I get this error:
System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 


What I have to change in my code?
Or maybe I have to change something in Windows (Windows 7) - My firewall is turned off.. But I don't do nothing with Incoming/outcoming rules...
Posted
Comments
Kim Togo 20-Jun-11 13:33pm    
Have you tried PuTTY and have it make a SSH connection, just to confirm that the remote party is answering.
mnd017 20-Jun-11 13:51pm    
Good idea. I can't connect using putty.
To make sure: All I have to do is: Fill "Host Name" and check "SHH" in Connection type. Yes? or maybe something else ?
Kim Togo 20-Jun-11 13:54pm    
Yes that is right. When the remote party accepts the SSH connection, a certificate is presented that has to be accepted.
mnd017 20-Jun-11 13:58pm    
In "Connection" -> "SSH" section I found "Protocol options" or "Encryption options" - maybe change something here ?

So.. I don't need to have any login or password to open the session ?

In that case.. there must be a mistake on the server side, right?
Kim Togo 20-Jun-11 15:24pm    
You do not have to change anything i PuTTY, just select SSH protocol and type in ip or hostname and then connect.

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