|
| Socket close of one client |
| Iniciado por guest, 02,ago. 2016 18:06 - 5 respuestas |
| |
| | | |
|
| |
| Publicado el 02,agosto 2016 - 18: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? TIA |
| |
| |
| | | |
|
| | |
| |
| Publicado el 02,agosto 2016 - 19:16 |
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 |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,agosto 2016 - 08:35 |
Hi Stewart, I've already tried that, and it kicks off all the clients, sadly... |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,agosto 2016 - 11:14 |
| 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 ... |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,agosto 2016 - 13: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, Ken |
| |
| |
| | | |
|
| | |
| |
| Publicado el 03,agosto 2016 - 14:23 |
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, |
| |
| |
| | | |
|
| | | | |
| | |
|