Page 1 of 1

communication port

Posted: Mon 28 Nov 2011 18:12
by multimesut
I want to write a chat program. The following small application is not running. can cause? IdUDPClient1>IdUDPServer1 information does not come. Thank you ..

x.x.x.x=sever ip

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
ScSSHClient1.HostName:='x.x.x.x';
ScSSHClient1.Port:=443;
ScSSHClient1.User:='test';
ScSSHClient1.Password:='test';
ScSSHClient1.Connect;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
ScSSHChannel1.SourcePort:=5001;
ScSSHChannel1.DestHost:='x.x.x.x';
ScSSHChannel1.DestPort:=1987;
ScSSHChannel1.Connect;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
IdUDPServer1.DefaultPort:=5001;
IdUDPServer1.Active:=true;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
IdUDPClient1.Host:='91.93.61.60';
IdUDPClient1.Port:=1987;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
IdUDPClient1.Send('aq');
end;

procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
  ABinding: TIdSocketHandle);
var
stream : TStringStream;
begin
  try
  stream := TStringStream.Create('');
  stream.CopyFrom( AData, AData.Size);
  Memo1.Lines.Add(ABinding.PeerIP+'-'+stream.DataString)
  finally
  stream.Free;
  end;
end;

Posted: Tue 29 Nov 2011 09:05
by Dimon
Try to change the following code:

Code: Select all

ScSSHChannel1.SourcePort:=5001; 
ScSSHChannel1.DestHost:='x.x.x.x'; 
ScSSHChannel1.DestPort:=1987; 
ScSSHChannel1.Connect; 
to the code:

Code: Select all

ScSSHChannel1.SourcePort:=1987; 
ScSSHChannel1.DestHost:='x.x.x.x'; 
ScSSHChannel1.DestPort:=5001; 
ScSSHChannel1.Connect; 

:(

Posted: Tue 29 Nov 2011 10:17
by multimesut
I'm sorry does not work. I want to do it too. goal is to make an application, such as msn. (mini chat) "1 server, many client" note:ssh server running this program in a different place.

thank you for help.

Posted: Tue 29 Nov 2011 15:32
by Dimon
When performing local port forwarding, TScSSHChannel listens to the port specified in TScSSHChannel.SourcePort, receives data, encodes and transmits it to SSH server. Server decodes data and transmits it to UDP server. Therefore your UDP server must run on computer where SSH is available server or on host to which SSH server has access.

You can find detailed information about it in the "SSH-tunnel principles" topic of SecureBridge help.

..

Posted: Wed 30 Nov 2011 07:46
by multimesut
programs that have a connection between two computers. sent the attached image. I want to do like that.

Image

Posted: Wed 30 Nov 2011 14:22
by Dimon
For this purpose you can use events of the TScSSHServer component.
You can look at the example of handling these events in the SSHServerService demo.