Okay, ive never used winsock before..But i have a tictactoe game and im wondering how i could make it mulitplayer. I have an array of 9 labels, id just like to know how i could send the data to the other player what label and what letter to select. I think i could get the rest from there.
Are they in an array? I'd just send (r,c,0) or (r,c,1). Have each side send over a WINNER message to the other side. Do you have Pino's Winsock sample?
Get it runing on your computer first and see how it works.
I don't have a link, but I downloaded it the other day. Just run each program in its own IDE at the same time. Make sure you unzip it into two separate folders (make sure the Use Folder Names button is checked)
wait, so i have to run two different programs to get it to work? Theres no way that it can be both server and client(i guess?). Id really like to have one .exe instead of two..
not what i want..i want to be able to whoever connects first to be server, and who ever is connected to, to be the client (or something similar) i dont want the option to be server or client.
Well, that was more of an example. You would have to have a way, of notifying the other program who is did what first. Without a connection, I dont know how to really do that. I think I might know one way, let me go find the source.
What you might be able to do, is when the program loads, start listening for a connection. Then have a command button that connects via like a client. So it would work like this
1.Program starts, listening for connections
2. Who ever clicks on connect first, will start the connection
3. Display a messagebox saying "Connected" so both users know they are connected, and wont try to connect.
If you dont know how to listen, and request a connection, read Pinos tut.
Open the client, and start it running,
Start the server in another instance of VB and start it running. Click the button.
Go back to the client and click connect. See connected message.
Now you are connected. Have both windows side by side.
You could have the same game be client or server, just the first one that hits listen is the server. There has to be a way for someone to tell the other to start listening for traffic. If you put a server in the middle, it can listen to more than one client and pass traffic back and forth.
You might be able to have winsock1 and winsock2 running in the same program, where winsock1 is always the client and winsock2 is always the server. Only one wil work at a time, and talk to the opposite side of the conversation.
You need the Server to control who goes first, for instance. It doesn't have to actually go first, but the choice would be sent to it, that gets sent to either itself or the client. The "Your Move" would light up on the correct panel.
Best way to check it is just to run it locally. If it works, then you did it right, and it will work as long as it can pass the firewalls in the middle.
I'm telling you I ran it on my laptop using 127.0.0.1 for the client and the server.
I told you how to do that up near the top using two versions of the IDE or compile it and run two .exes
Try PINO's version so you're convinced that it works.
System Messages - For information regarding wincok errors etc,
Incomming Data - Data recieved from another app
Sent Data - data we have sent to the other app.
To test this you will need to compile there is an exe with the source which has been compiled for you. Run it twice and click listen (first) on one and connect on another then send data between them, source is also included.