Winsock 2 Problem
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.
Make sure you check that you've opened the port number you are using on your router if you are using one.
~Graham
~Graham
----
Senior Rendering Engineer @ Frostbite
Previously at BioWare
Author of Game Engine Toolset Development
http://www.frostbite.com/2016/03/optimizing-the-graphics-pipeline-with-compute/
http://blog.bioware.com/2013/07/25/staff-blog-graham-wihlidal-senior-software-engineer/
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.
check for an error returned and use WSAGetLastError to narrow it down. all the errors are listed in the MSDN docs.
Of corse I'm checking for errors along the way. I'm new to winsock, not an idot.
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.
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.
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.
agin sorry it came out so rude.
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)
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)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement