Connecting to Self

Started by
1 comment, last by Unconquerable 17 years, 9 months ago
I'm playing around wtih Johnnie's Winsock tutorials ( http://johnnie.jerrata.com/winsocktutorial/). I'm trying to connect to myself via the client while the host is running. So I'm using 127.0.0.1. But when i try to connect, i get a winsock error that the connection was refused? I'm new to this and was wondering if anyone could help. Thanks.
Advertisement
You're probably connecting to the wrong port. The server needs to bind to a known port (say, 54321), and the client needs to connect to that specific port. 127.0.0.1 is like a street name ("your computer") -- you also need the right house number to connect.

Btw: ports should be passed through htons() before being passed to bind() or connect().
enum Bool { True, False, FileNotFound };
Thanks that worked.

This topic is closed to new replies.

Advertisement