NetTalk Central

Author Topic: Close a particular connection  (Read 19356 times)

Rick Martin

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Close a particular connection
« on: April 17, 2008, 01:05:53 PM »
Hi All,

I have a server application that accepts multiple connections from clients. I am storing the FromIP, SockID, and OnSocket values in a queue.
There are conditions where I want to close a particular client's connection but still leave the others running and be able to accept new requests.

I've tried using CloseServerConnection passing in the OnSocket and SockID fields from my queue.  This seems to close down the server altogether. I cannot start a new client and connect. Is this the right method for this?

TIA,
Rick

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Close a particular connection
« Reply #1 on: April 18, 2008, 07:43:50 AM »
Hi Rick,

yes that is the right method.
The WebServer calls that exact method whenever it finishes sending a reply. The call looks like this;
WebServer.closeServerConnection(self.RequestData.OnSocket,self.RequestData.SockID)

So that makes me think it's something else that you're doing that's killing the server, because the call above clearly seems to work ok.

cheers
Bruce

Rick Martin

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Close a particular connection
« Reply #2 on: April 18, 2008, 07:56:15 AM »
Hi Bruce,

Here is a little more info.

In the Process method I capture the data and connection information in a queue with this code:

  case self.Packet.PacketType
  of NET:SimpleAsyncOpenSuccessful
  of NET:SimpleIdleConnection
  of NET:SimplePartialDataPacket
  orof NET:SimpleWholeDataPacket
    MyString = self.packet.bindata[1 : size(MyString)]
    RequestQueue.MyDataInfoGrp  = MyString
    RequestQueue.FromIP  = self.packet.FromIP
    RequestQueue.SockID  = self.packet.SockID
    RequestQueue.OnSocket  = self.packet.OnSocket
    ADD(RequestQueue)

The in the Event:Timer I process and remove the records from the RequestQueue.
For this particular command I am doing the following.
            MyDataInfoGrp.Status = ERROR_SUCCESS
          NetLicServer.PrepAndSend(RequestQueue.FromIP,RequestQueue.SockID,RequestQueue.OnSocket)
            NetLicServer.CloseServerConnection(RequestQueue.OnSocket, RequestQueue.SockID)

I am getting the success status back in the client. If I load a new  client it cannot connect to the server.

All of my other commands are working fine.
Any ideas?

Thanks,
Rick


Rick Martin

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Close a particular connection
« Reply #3 on: April 21, 2008, 10:53:25 AM »
Never mind.  :-[

For the close command I was not deleting my entry in the command queue. So it was stuck redoing the same command over and over  and never responding to new requests/commands.

Oh well.

Thanks,
Rick