procedure TFrmUpdate.StartServerClick(Sender: TObject); begin with TCPServer do begin Active := False; DefaultPort := StrToInt(EdPort.Text); Active := True; LogMemo.Lines.Add(DateTimeToStr(Now)+' 服务已经启动!(Port: '+EdPort.Text+')'); end; end;procedure TFrmUpdate.StopServerClick(Sender: TObject); begin with TCPServer do begin Active := False; LogMemo.Lines.Add(DateTimeToStr(Now)+' 服务已经停止!'); end; end;
To hongqi162(失踪的月亮)谢了,请问你用的是TTcpServer?我没找到 DefaultPort 这个属性DefaultPort := StrToInt(EdPort.Text);
At design time, set Active to True to make the socket open a connection when the application starts running (the default value is False). At runtime, use the Open or Close method to open or close the connection. 用localport和open难道不行吗? 也顶 :)
begin
with TCPServer do
begin
Active := False;
DefaultPort := StrToInt(EdPort.Text);
Active := True;
LogMemo.Lines.Add(DateTimeToStr(Now)+' 服务已经启动!(Port: '+EdPort.Text+')');
end;
end;procedure TFrmUpdate.StopServerClick(Sender: TObject);
begin
with TCPServer do
begin
Active := False;
LogMemo.Lines.Add(DateTimeToStr(Now)+' 服务已经停止!');
end;
end;
这段代码还是没用!Active := True;后,我使用自己编的测试,还是显示端口未打开
http://expert.csdn.net/Expert/topic/2491/2491672.xml?temp=.8631098
用localport和open难道不行吗?
也顶 :)
正常情况下,close以后,再open是没有错的,
致少我还没错过