Recent

Author Topic: can i make server?  (Read 68985 times)

shs

  • Sr. Member
  • ****
  • Posts: 310
Re: can i make server?
« Reply #195 on: November 18, 2017, 01:48:17 am »
i did that and there's no more error message but it's not fully disconnected
if the server sends the message the client still can get message
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button3Click(Sender: TObject);
  2. begin
  3.   ListenerSocket.closesocket;
  4.   listenersocket.free;
  5.   timer2.enabled:=false;
  6.   timer1.enabled:=false;
  7.   button3.enabled:=false;
  8.   button1.enabled:=true;
  9. end;                        

rvk

  • Hero Member
  • *****
  • Posts: 6169
Re: can i make server?
« Reply #196 on: November 18, 2017, 01:56:01 am »
You should close and free the ListenerSocket last in the procedure for good form. The timer won't run inside the procedure but it's cleaner to free them last.

The reason you can still communicate is because the Connections-sockets themselves (the array) are still connected. You only shut down the listening for NEW connections. If you want to close down all sockets you also need to clean up the connection-socket array.

shs

  • Sr. Member
  • ****
  • Posts: 310
Re: can i make server?
« Reply #197 on: November 18, 2017, 02:36:54 am »
thank you it works now :)
so it's better to use thread instead of timer?

 

TinyPortal © 2005-2018