Delphi: TTcpServer, connection reset when reading

有些话、适合烂在心里 提交于 2019-12-10 00:12:40

问题


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:


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



来源:https://stackoverflow.com/questions/1591256/delphi-ttcpserver-connection-reset-when-reading

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!