august wrote:
for example if I connect to http://66.28.68.70:8000/puredata.ogg and nothing is there at that server on that port, it returns non-0 with an error and everything is fine.
But, if I try to connect with http://66.28.68.70:3200/puredata.ogg, it hangs completely.
Hi August,
what's the difference between the two URLs (in terms of server settings, mountpoints and the like)?
The only difference is the port numbers. On 8000, there was an icecast or shoutcast server running at one point, but not anymore. The connect() call properly checks for a connection and returns an error.
I'm not sure why, but port 3200 (as well as other ports) will cause connect() to hang.
This may have something to do with blocking and non-blocking mode on the socket.
I'm now going over select, connect and socket man pages as Tom pointed out.
As far as I understand connect() can connect
to a socket in listening state and the socket we're connecting to has to know what to do when it receives a connection request.
right, but the app will hang for a very LONG time. I'm guessing this has to do with the socket being in blocking mode.
In case you
accidentally try to connect to a socket meant to be used for connectionless transfers (i.e. UDP and thus not in listening state) a connect() call might block since it just doesn't get served from the other side. This might also happen in case the server crashes...
actually, I think Tom's suggest was on track....to set the socket in non-blocking mode, and then mabey poll() the filedescriptor ?????
any examples?
-august.