-
Mar 28th, 2012, 01:07 AM
#1
Thread Starter
Member
TCP/IP question
I got a simple game where you move around a painted background. Anyway, moving the character on the background is easy enough, but getting it to do it with a remote client is a bit tricky. I THINK the variables needed would be location(x, y) and which way the char is facing. I am very new to tcp programming and looking for any advice or pointers before i start the coding process.
-
Mar 28th, 2012, 01:29 AM
#2
Thread Starter
Member
Re: TCP/IP question
Oh, I believe I need it on a new thread - so that it can search for incoming clients without locking up the game, and also allow clients to come and go as they please. I know from previous experience that I'm going to have trouble sending data created on that thread to the main thread.. the one with the text boxes used to communicate.
-
Mar 28th, 2012, 01:37 AM
#3
Re: TCP/IP question
You might like to start by following the CodeBank link in my signature and checking out my Asynchronous TCP thread. That demonstrates how to make asynchronous calls using the TcpListener and TcpClient classes so as not to lock up the UI and also how to get the data from those background threads to the UI thread.
That example passes text messages back and forth but all data has to be passed in binary form, i.e. using Byte arrays. The example convert the text to binary and back again, so you just have to provide your own layer for converting your data to binary and back again. How you do that will depend on the data. You might use a BinaryFormatter, a BinaryWriter, some other method or a combination of methods.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|