Raised This Month: $51 Target: $400
 12% 

Sockets, infinite looping


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 12-25-2009 , 11:52   Sockets, infinite looping
Reply With Quote #1

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? :/
Spunky is offline
Send a message via AIM to Spunky
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 12-25-2009 , 12:04   Re: Sockets, infinite looping
Reply With Quote #2

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
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 12-25-2009 , 12:06   Re: Sockets, infinite looping
Reply With Quote #3

Quote:
Originally Posted by joropito View Post
If you make an infinite loop, you're going to hang the server.
Really? I had no idea.

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.
Spunky is offline
Send a message via AIM to Spunky
Drak
Veteran Member
Join Date: Jul 2005
Old 12-25-2009 , 13:41   Re: Sockets, infinite looping
Reply With Quote #4

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)
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 12-25-2009 , 14:34   Re: Sockets, infinite looping
Reply With Quote #5

If I lower the timeout, I don't get a response though. Weird.
Spunky is offline
Send a message via AIM to Spunky
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 23:09.


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