locked
How to connect to a server in io extension RRS feed

  • Question

  • i want to make a multiplayer game or at least a program to send text to another person

    how do I do this? it is really confusing. what ip adress do i put in. i really need help


    chase morell

    Sunday, March 3, 2013 1:00 AM

Answers

  • It is not so hard once you get the hang of it. I will explain how to do it with 2 players to make it more simple.

    Both players will need to start an IOTCPServer and an IOTCPClient. Player 1's client will connect to Player 2's server (using Player 2's server IP and port). Player 2's client will connect to player 1's server (using Player 1's server IP and port).

    Player 1's client can now send messages to player 2's server and player 2's server can now send messages to player 1's server. For example, with a chess game, when Player 1 makes a move, you could use player 1's client to send his pieces' locations to player 2's server. When Player 2 makes his move, his client will send player 1's server his pieces' locations and this will continue until the game is over.

    The best sample code is available in the "/Samples/IOTCPServer - IOTCPClient/" folder.

    Please post back if you have any more questions! =)  


    Please mark any answers and "vote as helpful" any posts that help you!

    • Proposed as answer by litdev Sunday, March 3, 2013 10:05 AM
    • Marked as answer by Nonki Takahashi Monday, March 11, 2013 1:12 PM
    Sunday, March 3, 2013 2:15 AM
    Answerer
  • No, the Wi-Fi password makes no difference. The TCP/IP protocol I implemented can be thought of like a webpage: Google.com, for example, can request data from you computer but does not require a Wi-Fi password. This is because it does not connect to your home network.

    You can think of your computer as an apartment complex. It has a street address (your IP). It has many apartments inside of it, each unit with its own door (a TCP/IP port). Some of these doors/ports will be open while others will be closed and locked.

    If you are still having problems, you need to do some port forwarding (opening doors). Googling "port forwarding" will find lots of helpful guides (I will not post a link here since I do not know what OS you are using).


    Please mark any answers and "vote as helpful" any posts that help you!

    Monday, March 4, 2013 10:55 PM
    Answerer

All replies

  • It is not so hard once you get the hang of it. I will explain how to do it with 2 players to make it more simple.

    Both players will need to start an IOTCPServer and an IOTCPClient. Player 1's client will connect to Player 2's server (using Player 2's server IP and port). Player 2's client will connect to player 1's server (using Player 1's server IP and port).

    Player 1's client can now send messages to player 2's server and player 2's server can now send messages to player 1's server. For example, with a chess game, when Player 1 makes a move, you could use player 1's client to send his pieces' locations to player 2's server. When Player 2 makes his move, his client will send player 1's server his pieces' locations and this will continue until the game is over.

    The best sample code is available in the "/Samples/IOTCPServer - IOTCPClient/" folder.

    Please post back if you have any more questions! =)  


    Please mark any answers and "vote as helpful" any posts that help you!

    • Proposed as answer by litdev Sunday, March 3, 2013 10:05 AM
    • Marked as answer by Nonki Takahashi Monday, March 11, 2013 1:12 PM
    Sunday, March 3, 2013 2:15 AM
    Answerer
  • What IP address do you use?

    chase morell

    Sunday, March 3, 2013 3:10 AM
  • For player 1: Connect to player 2's IP.

    For player 2: Connect to player 1's IP.


    Please mark any answers and "vote as helpful" any posts that help you!

    Sunday, March 3, 2013 3:21 AM
    Answerer
  • I know that but what actual number do I use as the IP address ? In the sample it had a number as the IP address, what number do I use for my project? A random one?

    chase morell

    Sunday, March 3, 2013 12:54 PM
  • A random IP address would not work as the server and client would not be able to connect.

    The sample uses my computer's local IP address. Here is how you figure out which IPs to use:

    1) If the client and the server are on the same home network, use "ipconfig" from the command prompt and use the "IPv4 Address"

    2) If you are connecting two computers not on the same home network, you first need to use Windows Firewall and create an exception for your server's IP and port. Next, use something like http://whatismyipaddress.com/ to get your public IP and get the client connect to that.


    Please mark any answers and "vote as helpful" any posts that help you!

    Sunday, March 3, 2013 3:27 PM
    Answerer
  • me and my friend are not on the same network and we tried to connect using the IP adress giving to us on the whatismyipadress.com site and it would not connect. I used 2 computers on the same network and i used the local ip and it worked flawlessly. what am i doing wrong? do i need to use the deimal.

    chase morell


    Monday, March 4, 2013 2:13 AM
  • Yes, you need to use the decimal (e.g. XXX.XXX.XXX.XXX).

    Your problem is probably being caused by a firewall. You need to open the port you want in your firewall (Google "windows firewall port forwarding"). If that does not work, you may need to open a port on your router (go to the router config page in your browser and open the port you need).


    Please mark any answers and "vote as helpful" any posts that help you!

    Monday, March 4, 2013 2:34 AM
    Answerer
  • if the wifi has a password will that make a difference


    chase morell

    Monday, March 4, 2013 2:51 AM
  • No, the Wi-Fi password makes no difference. The TCP/IP protocol I implemented can be thought of like a webpage: Google.com, for example, can request data from you computer but does not require a Wi-Fi password. This is because it does not connect to your home network.

    You can think of your computer as an apartment complex. It has a street address (your IP). It has many apartments inside of it, each unit with its own door (a TCP/IP port). Some of these doors/ports will be open while others will be closed and locked.

    If you are still having problems, you need to do some port forwarding (opening doors). Googling "port forwarding" will find lots of helpful guides (I will not post a link here since I do not know what OS you are using).


    Please mark any answers and "vote as helpful" any posts that help you!

    Monday, March 4, 2013 10:55 PM
    Answerer