network disconnects?

Just starting out? Need help? Post your questions and find answers here.
pjsmith67
User
User
Posts: 21
Joined: Thu Apr 26, 2018 3:09 pm

network disconnects?

Post by pjsmith67 »

Hi, new to PB, but not programming in general. I'm tinkering around with creating a threaded network server. Doesn't do anything yet but acknowledge when it gets a connection.

The problem I'm having is that it doesn't acknowledge network disconnects. It never receives the #PB_Network_Disconnect event. From what I've read, PB does not get this event unless another PB program closes the connection. But what about programs not written in PB? And what about if the network just drops the connection? How do I know when that happens? Although I am an experienced programmer, haven't done a lot with networking.

I'm running PB on a OS X Sierra, 10.12.6, but am not using any platform specific code.

Thanks!

Phil
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: network disconnects?

Post by Bisonte »

In PB, the client does not notice if the server connection is broken. The server, on the other hand, notices when a client says goodbye.

That's why we do this with "Pings". This means that a ping is sent at regular intervals, which must be returned, otherwise the server or client closes the connection.
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
pjsmith67
User
User
Posts: 21
Joined: Thu Apr 26, 2018 3:09 pm

Re: network disconnects?

Post by pjsmith67 »

I run the network example and connect to it using a UNIX utility called netcat. Server acknowledges the connection. But when I kill netcat, the server does not get a disconnect message. So, I assume I have to do a ping like suggested or some kind of timeout value... don't hear from the client for X amount of time, kill the connection/thread.
Post Reply