Archived

This topic is now archived and is closed to further replies.

keethrus

ARGH! "Socket not connected"?!

Recommended Posts

Im trying to create a simple async socket, and I dont get any errors when Im getting the hostname of the server I want to connect to or when Im creating the socket or when Im connecting to the server. But after I connect it takes like 10 seconds for my dialogBox to receive an FD_CONNECT event, and it never recieves anything else. So I have the dialogBox Post a FD_WRITE message. Inside my FD_WRITE code, I try to send some data the server, but I get the WSAENOTCONN error, which means the socket is not connected. But I didnt get any error message when I called connect to connect to the server. Im baffled. Any body have any suggestions? - Jeremiah inlovewithGod.com

Share this post


Link to post
Share on other sites
Thanks for the advice,

After putting in various error checking spots in my code, Ive found out that its returning "WSAETIMEDOUT" ( Attempt to connect timed out without establishing a connection. ) which explains why it always took 10 seconds. When I setup a server on my local machine and connect to "localhost" everything works fine and quickly, but it times out when I try to connect to an outside server. However, the same server comes up fine in my browser. One note is that I am living on a campus where I connect to the internet through their network.

Any thoughts?

- Jeremiah

inlovewithGod.com

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You will probably find that there are very few open ports if you are on campus. Maybe try a port scan?

Share this post


Link to post
Share on other sites
Running a port scan over a campus network may be a violation of the terms of use of your network. Certain unfriendly campuses may view it as grounds for expulsion.

In any case, for the outside server are you sure that the port you''re connecting to is running a service you want? Connecting a browser to it only proves that the port for http is open.

Share this post


Link to post
Share on other sites
I think I know what the problem is. My program is trying to access port 80, so checking the server in the browser works in my case. But my browser has to use a proxy to connect to the internet. Anybody know any good sites or function calls so winsock uses the proxy?

- Jeremiah

inlovewithGod.com

Share this post


Link to post
Share on other sites
Do you know what kind of proxy is being used? Some proxies are transparent and don''t need special handling. As you''re having troubles, this probably isn''t one of them. Some proxies you can use an external application to handle the proxy communications for you. IIRC, this can be done with SOCKS4/SOCKS5 proxies. In that case you can write your application normally and run the external program to launch it. If you can''t find an application to do that, then you may need to deal with proxy directly. Some proxy types have pre-written socket wrappers. In those cases you just specify a few extra parameters but otherwise treat them as normal sockets.

Share this post


Link to post
Share on other sites
well, i guess the proxy at my school is considered a "normal" http proxy? its not socks4 or socks5. what i had to do is instead of connecting directly to the server and ask for a page like so: "GET pagename.html HTTP/1.0\r\n\r\n", i had to connect to the proxy itself and ask for the page with the site name like so: "GET http://example.com/pagename.html HTTP/1.0\r\n\r\n"

not too much of a hassle at all really.

of course my program will have to deal with socks4 and 5, but im sure it wont be anymore of a hassle than this. just have to find the references that tell you what they want you to send them.

- jeremiah

inlovewithGod.com

Share this post


Link to post
Share on other sites