Jump to content
  • Advertisement
Sign in to follow this  
Josh5231

Winsock 2 Problem

This topic is 5012 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was just woundering if somone could tell me how i can use winsock2 to connect a anouther comp to my server over the internet. I have used MSDN example and simply put in my IP address. The problem is that when I try to run the program on anouther comp it allways tells me it can't connect. Thanks for the help. Josh.

Share this post


Link to post
Share on other sites
Advertisement
Are you checking each step along the way making sure that there was no errors? like when creating the socket, connecting, or whatever it is that you're doing.

check for an error returned and use WSAGetLastError to narrow it down. all the errors are listed in the MSDN docs.

Share this post


Link to post
Share on other sites
Boy that sure was hostile. How am I supposed to know? That's jsut the first question to ask when you DON'T state you're doing it. For all I knew you could have had an error on creating the socket considering how uninformative your post is.

edit:
er and I didn't mean that to sound hostile back. I just wasn't sure if it was something you were doing or a network problem. Just tryin to help.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
wow hes retarded he just copied the code from msdn.com which is going to do him jack shit and you dont put in your ip you put in the servers

Share this post


Link to post
Share on other sites
Look, I didn't mean for it to come off as rude as it did. Sorry its just been a bad week. What i want to know is am I suppose to have the client connect right to my IP and port that the server program is running on or do I have to do something else?
agin sorry it came out so rude.

Share this post


Link to post
Share on other sites
No problem. All you should have to do for a simple TCP connection is just have the server bind and listen to a specific port. When you get a connection request, call accept() to create a seperate socket for talking to the client over. Then you'll need to find the IP address that's exposed to the network that the other computer will find you from (I say that because you might have multiple network cards or something). Then just have the client create a socket and connect to that IP and port number. If everything is simple and both computers are directly exposed to the same network (not behind a router or firewall of some kind) then that should be all you need to do. If either are then you'll have to use some kind of port forwarding or be a DMZ host or whatever.

If you're new, just be sure to watch out for things like network byte order when setting the IP and port. Keep it nice and simple and debug each step of your program till you figure out where something is going wrong (if it's a code mistake)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!