Hi,
I made a small program, which read data form COMPort, and send it over TCP/IP to 3 other computers, all LAN. I used tutorial, which i found here(big thanks, btw). So I used TClientSocet and TServerSocket components. I have one client and 3 servers, client is reading and sending data to all 3 servers, all the time, it worked great, until... I had one more computer, which was on another subnet(Connection through router), and right now, i can only establish connection, but i cannot receive data. So.. what shell i do first? Can i still use TClientSocet and TServerSocket components, or i need another ones? Is there any tutorials? Maybe someone has code snippets?
I really hope, someone can help me..i will appreciate every help, thanks
I made a small program, which read data form COMPort, and send it over TCP/IP to 3 other computers, all LAN. I used tutorial, which i found here(big thanks, btw). So I used TClientSocet and TServerSocket components. I have one client and 3 servers, client is reading and sending data to all 3 servers, all the time, it worked great, until... I had one more computer, which was on another subnet(Connection through router), and right now, i can only establish connection, but i cannot receive data. So.. what shell i do first? Can i still use TClientSocet and TServerSocket components, or i need another ones? Is there any tutorials? Maybe someone has code snippets?
Code:
///////////////////////////////////////////////////////////////////////////
///Client program
//Checking connectivity
function Tform1.checkTCP: string;
var
i:string;
flag:boolean;
begin
Form1.ClientSocket1.Port := 26;
Form1.ClientSocket1.Host := '172.16.1.4';
Form1.ClientSocket1.Active:=true;
Form1.ClientSocket2.Port := 24;
Form1.ClientSocket2.Host := '172.16.1.6';
Form1.ClientSocket2.Active:=true;
Form1.ClientSocket3.Port := 25;
Form1.ClientSocket3.Host := '172.16.1.8';
Form1.ClientSocket3.Active:=true;
Form1.ClientSocket4.Port := 23;
Form1.ClientSocket4.Host := '192.168.0.123';
Form1.ClientSocket4.Active:=true;
Form1.ClientSocket5.Port := 27;
Form1.ClientSocket5.Host := '172.16.1.12';
Form1.ClientSocket5.Active:=true;
end;
//Sending data
procedure TForm1.Button2Click(Sender: TObject);
label check;
var flag:boolean;
begin
check:
//Sleep(100);
CloseHandle(ComFile);
OpenComPort();
flag:=true;
i:=0;
button1.Click;
ReadText();
//Edit2.text:= s;
ClientSocket1.Socket.SendText(Edit2.Text+' ');
ClientSocket2.Socket.SendText(Edit2.Text+' ');
ClientSocket3.Socket.SendText(Edit2.Text+' ');
ClientSocket4.Socket.SendText(Edit2.Text+' ');
ClientSocket5.Socket.SendText(Edit2.Text+' ');
If ((ClientSocket1.Active= true) and (ClientSocket2.Active= true) and (ClientSocket3.Active= true) and (ClientSocket4.Active= true) and (ClientSocket5.Active= true)) then begin
CloseHandle(ComFile);
goto check;
end;
end;
//Server program
//assign ports
procedure TForm1.FormCreate(Sender: TObject);
begin
ServerSocket1.Port := 26;
ServerSocket1.Active := True;
ServerSocket2.Port := 24;
ServerSocket2.Active := True;
ServerSocket3.Port := 25;
ServerSocket3.Active := True;
ServerSocket4.Port := 23;
serverSocket4.Active := True;
end;
//Receiving data
procedure TForm1.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
try
Form1.Edit1.Text:=Socket.ReceiveText ;
except
//ff
end;
end;
procedure TForm1.ServerSocket2ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
try
Form1.Edit1.Text:=Socket.ReceiveText;
except
//ff
end;
end;
procedure TForm1.ServerSocket3ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
try
Form1.Edit1.Text:=Socket.ReceiveText ;
except
//ff
end;
end;
procedure TForm1.ServerSocket4ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
I really hope, someone can help me..i will appreciate every help, thanks