I'm trying to send a string from my local machine to a remote one on our
LAN, but the message isn't getting through. Can anybody see what I'm doing
wrong here?

My client (local) code:

procedure TForm15.Button1Click(Sender: TObject);
var
  sock: TTCPBlockSocket;
begin
  sock:= ttcpblocksocket.Create;
  try
    sock.ConvertLineEnd := True;
    sock.Connect('17.229.3.2', 'echo');
    sock.SendString('Anybody want a peanut?'+crlf);
  finally
    sock.Free;
  end;
end;

I'm running the EchoSrv demo app on another machine ('17.229.3.2'), with
slightly modified code:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@
unit echo;

interface

uses
  Classes, blcksock, synsock, winsock; //TSocket was unidentified. Is this
the right unit to add?

type
  TTCPEchoDaemon = class(TThread)
  private
    Sock:TTCPBlockSocket;
  public
    Constructor Create;
    Destructor Destroy; override;
    procedure Execute; override;
  end;

  TTCPEchoThrd = class(TThread)
  private
    Sock:TTCPBlockSocket;
    CSock: TSocket;
  public
    Constructor Create (hsock:tSocket);
    procedure Execute; override;
  end;

implementation

uses
  SysUtils, //for Trim()
  Dialogs; //for ShowMessage()

{ TEchoDaemon }

Constructor TTCPEchoDaemon.Create;
begin
  sock:=TTCPBlockSocket.create;
  FreeOnTerminate:=true;
  inherited create(false);
end;

Destructor TTCPEchoDaemon.Destroy;
begin
  Sock.free;
end;

procedure TTCPEchoDaemon.Execute;
var
  ClientSock:TSocket;
  s: String;
begin
  with sock do
    begin
      CreateSocket;
      setLinger(true,10);
      bind('0.0.0.0','echo');
      listen;
      repeat
        if terminated then break;
        if canread(1000) then
          begin
            ClientSock:=accept;
            s := sock.RecvString(30000);
            if Trim(s) <> '' then
              ShowMessage(s);
            if lastError=0 then TTCPEchoThrd.create(ClientSock);
          end;
      until false;
    end;
end;

{ TEchoThrd }

Constructor TTCPEchoThrd.Create(Hsock:TSocket);
begin
  Csock := Hsock;
  FreeOnTerminate:=true;
  inherited create(false);
end;

procedure TTCPEchoThrd.Execute;
var
  s: string;
begin
  sock:=TTCPBlockSocket.create;
  try
    Sock.socket:=CSock;
    sock.GetSins;
    with sock do
      begin
        repeat
          if terminated then break;
          s := RecvPacket(60000);
          if lastError<>0 then break;
          SendString(s);
          if lastError<>0 then break;
        until false;
      end;
  finally
    Sock.Free;
  end;
end;

end.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@

When I click "Button1" on my local machine (with echosrv running on the
remote machine), the two machines DO talk to each other, but the string is
not being sent, apparently.

Here is what Wireshark shows:

1425    7.003763        17.229.3.93     17.229.3.2      TCP     2081 > echo
[SYN] Seq=0 Len=0 MSS=1460
1426    7.003845        17.229.3.2      17.229.3.93     TCP     echo > 2081
[RST, ACK] Seq=0 Ack=1 Win=0 Len=0

But "Follow TCP Stream" shows nothing--the string has been swallowed up
somewhere along the line...

--Clay Shannon

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to