Delphi: TTcpServer, connection reset when reading

1.5k views Asked by At

I'm trying to implement a Fitnesse Slim server for delphi, but have some problems with the communication.

Fitnesse will start my process, and give me a portnumber as a commandline argument.

Then I'm supposed to create a socket at the given portnumber, and Fitnesse will connect to that port.

I'm using a TTcpServer for the job:

TcpServer1.LocalPort := ParamStr(ParamCount);
TcpServer1.Active := true;

In the OnAccepted( )-event, I send the protocol version to use, as specified in the spec.

procedure TForm1.TcpServer1Accept(Sender: TObject;
  ClientSocket: TCustomIpClient);
var
  s: ansistring;
begin
  ClientSocket.Sendln('Slim -- V0.0', #10);
  setLength(s, 6);
  ClientSocket.ReceiveBuf(s, 6);
end;

When I call ReceiveBuf( ), the process ends, and fitnesse throws an exception:

java.net.SocketException: Connection reset

I have used oSpy to see what get sent and received. It shows that after my code sends the protocol version, fitnesse sends a message back, and that the connection is reset when I try to receive this message.

Does anybody know what the reason for this can be? Am I doing something completely wrong?

Btw, everything works ok when I use the java slim server that comes with fitnesse. oSpy then shows the same communication, up to the first read. While my attempt to read fails, this one works as expected.

1

There are 1 answers

1
Charles Faiga On

have a look at this web site for a delphi Fit server + source code