Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Another subnet

Status
Not open for further replies.

abyss616

Programmer
Aug 17, 2011
2
LV
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?

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 :)
 
Which version of Delphi are you using?

Which version of Windows are you using?

I am sure that I read somewhere that Windows XP Home Edition will only support a maximum of 4 computers on a local network. The XP Professional Edition does not have that restriction.

I am interested in which version of Delphi you have because I am experiencing problems using TCP/IP with Delphi 2009. I have tried both TServerSocket / TClientSocket and TTCPServer / TTCPClient components without success.

Andrew
 
i am using delphi 2007 and my OS is Windows 7 professional. Yep, i have heard, that delphi 2009 these components do not work fine. Well, the only solution i have right now, is port forwarding. It although would be the easiest solution
 
I've never experienced such issues, and I use those sockets all the time. I've actually wrapped the TServerSocket and TClientSocket into my own TJDServerSocket and TJDClientSocket which work on a command level with parameters. If I remember right, at least in Delphi 2010, those sockets don't come installed by default, as they are in Delphi 7. It could be something related to the fact that Delphi 7 was the last **stable** version before Embarcadero took it over.

JD Solutions
 
I think the limit for XP Home is 9 computers (all peer to peer).

Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top