Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 1 Jahr, 10 Monaten
Letzter Beitrag:
vor 1 Jahr, 10 Monaten
Beteiligte Autoren:
Yaku, KenKnight, Stewart Crisler, GuenterP

Socket close of one client

Startbeitrag von Yaku am 02.08.2016 16:06

Hi everyone,
I have several clients connected to a socket server via a single socket (all connected to the same socket, with a channel associated for each client)
What I'm trying to do is to implement the "Kick client" from the server...
I've tried SocketClose, but by doing that it closes the lone socket, kicking all the clients out...
Is there a "good" (or should i say best) way to do so?


From the WinDev documentation:

The communication channel opened by SocketAccept must be closed by SocketClose.

Are you using the channel name in SocketClose rather than the socket name? The documentation is not especially clear on that but I think that is how it works.

Stewart Crisler

von Stewart Crisler - am 02.08.2016 17:16
Hi Stewart,
I've already tried that, and it kicks off all the clients, sadly...

von Yaku - am 03.08.2016 06:35
Hi, of course, since you are using a single socket, closing that socket will kick off all of the clients. There's no way to define the address with SocketClose(...), only the port. Instead, you could deny communication for that client. Or, each client would have to communicate on a different port. However, if you close the socket, the client could restart communication at any time. So, you'd have a mechanism to deny communication anyway ...

von GuenterP - am 03.08.2016 09:14
Hi Yaku,

It sounds like you've defined your own custom bi-directional communication server and client. If this is the case, you have a couple of options:

1) For each SocketAccept() event you get a new channel name which represents the remove client's connection. If you want to kick from server, you do a socketClose(channelName) and the connection to that specific client is shutdown, but the rest of your connections are left alone.

2) You can issue your own 'kick command' back to the client and have that side close the connection to the server.

I wrote a small network stability tester which is basically a client / server package that makes a socket connection to a server from a client. The server periodically enumerates all the connections and sends a packet (ie KeepAlive) down to each client. If that packet fails, I know that the connection has been terminated and I do clean up from there.

Windev ships with an example that might point you in the right direction, it is called "WD Using Sockets".

Hope that helps.

Best regards,

von KenKnight - am 03.08.2016 11:14

Re: Socket close of one client [SOLVED]

Thank you all for your quick responses, especially because they've given me an input to go forward...
I've opted to go for a communication denial on the chosen client, by simply killing the thread/procedure that's in charge of reading the strings sent by the client just mentioned. The client itself doesn't immediately know that it has been kicked, but only on the next string sent. It is far from a "real-time kick" concept, but it works for me,

von Yaku - am 03.08.2016 12:23
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.