Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Pascal/Delphi

Pascal/Delphi Forum for discussing Borland Delphi and Pascal coding techniques, tips and tricks.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-26-2007, 12:00 PM
tosh5457's Avatar   
tosh5457 tosh5457 is offline
Newbie
 
Join Date: May 2007
Location: Portugal
Age: 16
Posts: 7
Rep Power: 0
tosh5457 is on a distinguished road
Default Delphi Sockets : Simple client and server program

Im gonna try to explain my problem:

i got 2 exe's (Client and server).
the client application sends strings to the server on button click and write the server response to a memo.
the server application gets client strings and sends back a message saying "Recebido".
When i start the client (with the server app already running) i get the message from server saying "Recebido", and when i send a message clicking the button the server sends the "Recebido" message. my problem is : when i send some string to the server again, the client doesnt write anything to the memo. i dunno if it is client or server's problem. here is the code of the client:

Code:
unit Cliente;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ScktComp;

type
  TForm1 = class(TForm)
    Cliente: TClientSocket;
    Edit1: TEdit;
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure ClienteRead(Sender: TObject; Socket: TCustomWinSocket);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  Cliente.Socket.SendText(Edit1.Text);
end;

procedure TForm1.ClienteRead(Sender: TObject; Socket: TCustomWinSocket);
begin
  Memo1.Lines.Add(Socket.ReceiveText);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  Cliente.Open;
end;

end.
and the server's:

Code:
unit Servidor;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ScktComp;

type
  TForm1 = class(TForm)
    Servidor: TServerSocket;
    procedure ServidorClientRead(Sender: TObject; Socket: TCustomWinSocket);
    procedure FormCreate(Sender: TObject);
    procedure ServidorAccept(Sender: TObject; Socket: TCustomWinSocket);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure TForm1.ServidorClientRead(Sender: TObject;
  Socket: TCustomWinSocket);
begin
  Servidor.Socket.Connections[0].SendText('Recebido');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
  Servidor.Active := True;
end;

procedure TForm1.ServidorAccept(Sender: TObject; Socket: TCustomWinSocket);
begin
   Servidor.Socket.Connections[0].SendText('Recebido');
end;

end.
help me please

Last edited by tosh5457; 05-26-2007 at 12:03 PM. Reason: didnt make myself clear
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Transmitting video capture from server to client (Newbie) MrNobody Visual Basic Programming 30 05-02-2008 05:18 PM
Access server file from client ahpooh Visual Basic Programming 1 09-06-2007 02:36 PM
[C] Server doesn't send a message on mailslot Alhazred C and C++ 3 08-13-2007 06:48 AM
Access server file from Client ahpooh Visual Basic Programming 2 02-14-2007 07:51 PM
Server side and client side Kaabi PHP Forum 6 07-30-2006 11:19 AM


All times are GMT -5. The time now is 03:34 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads