Jump to content
  • Advertisement
Sign in to follow this  
mnbvlk

socket help

This topic is 3828 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

how to create a socket ( in dev c++ 4.9.9.2) between my comp and 64.233.187.99 (which is google.com) i tried SOCKET sockfd; sockfd=socket(AF_INET,SOCK_STREAM,0); but does not know the meaning of various arguments i.e where to specify the ip address can anybody help please thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
This is a very good tutorial concerning linux sockets.
http://beej.us/guide/bgnet/
The socket() just creates a file descriptor.
Then you have to use the bind() command in which you give the ip and port number.
The tutorial says it all :P

Share this post


Link to post
Share on other sites
thanks for the links

i have another question ( i am actually a beginner in networks)

can two networks placed far apart in different towns can be connected by a router

also is something exists like this == ip address of a router .if it exists , then what does it mean

again remember ( i am actually a beginner in networks so questions may be strange)

Share this post


Link to post
Share on other sites
Quote:
Original post by mnbvlk
sorry , i forget to tell that iam working on windows xp and not linux
Beej's Guide is 99.9% relevant to WinSock too. The only differences I can think of offhand are that you need to call WSAStartup before making any socket calls, and the first argument to select() is ignored in WinSock.

Share this post


Link to post
Share on other sites
Quote:
Original post by mnbvlk
thanks for the links

i have another question ( i am actually a beginner in networks)

can two networks placed far apart in different towns can be connected by a router

also is something exists like this == ip address of a router .if it exists , then what does it mean

again remember ( i am actually a beginner in networks so questions may be strange)




are my questions strange??????????

Share this post


Link to post
Share on other sites
Quote:
Original post by mnbvlk
can two networks placed far apart in different towns can be connected by a router
Yes they can. Although they're likely to be connected by several routers (This is essentially how the Internet works).

Quote:
Original post by mnbvlk
also is something exists like this == ip address of a router .if it exists , then what does it mean
I don't quite understand what you mean. Your external IP is assigned by your ISP, and your internal LAN IP is assigned by your router (Assuming you have DHCP enabled). If you're asking if there's a way to get the IP of your router, then yes - you can get the default gateway through some Winsock calls. But that'll be your router's internal LAN IP (E.g. 192.168.0.1), not it's external IP as other machines see it.

Share this post


Link to post
Share on other sites
Original post by Evil Steve
Quote:
Original post by mnbvlk
can two networks placed far apart in different towns can be connected by a router
Yes they can. Although they're likely to be connected by several routers (This is essentially how the Internet works).

will there be several routers even if the networks is a private lan spread all over a city or just a single router


Share this post


Link to post
Share on other sites
Quote:
Original post by mnbvlk
will there be several routers even if the networks is a private lan spread all over a city or just a single router
Depends on the network. Although almost definitely - one router won't really be able to cope well with hundreds or thousands of connections.

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!