AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Sockets, infinite looping (https://forums.alliedmods.net/showthread.php?t=113310)

Spunky 12-25-2009 11:52

Sockets, infinite looping
 
This isn't a problem, just an inquiry. I originally tried this:

PHP Code:

while (socket_change(g_hSocket1000000)) 

This created an infinite loop, so I'm using a for loop instead. But does anybody know why that would happen? It should only return true if new data is in the socket, right? :/

joropito 12-25-2009 12:04

Re: Sockets, infinite looping
 
If you make an infinite loop, you're going to hang the server.

Just call once and it will return after socket change or timeout.

Use a task to call repeatedly

Spunky 12-25-2009 12:06

Re: Sockets, infinite looping
 
Quote:

Originally Posted by joropito (Post 1030735)
If you make an infinite loop, you're going to hang the server.

Really? I had no idea. :roll:

I'm not asking if it creates an infinite loop, I'm asking why that would create an infinite loop as it's only supposed to return true if there's new data in the socket.

Drak 12-25-2009 13:41

Re: Sockets, infinite looping
 
It's checking if there's data waiting. But because your timeout is so large. It consently checks over and over. Until it times out (the server "locks up" but it's actually still checking)

Spunky 12-25-2009 14:34

Re: Sockets, infinite looping
 
If I lower the timeout, I don't get a response though. Weird.


All times are GMT -4. The time now is 04:12.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.