client/server

koure

Active member
Joined
Sep 23, 2008
Messages
27
Programming Experience
Beginner
hi

I'm newbie to vb.net
I'm trying to develop a client/server application and I want to ask which is better way to send data from client to server. As an XML file or as a stream?
I would appreciate it if you could send me some samples

thank you very much
 
"Better" is going to be relative to your needs and goals.

The XML approach will likely be easier to code for a beginner, but will likely rely on a FileSystemWatcher to see the new file and act upon it, which means it will be a bit slower overall in terms of reaction times.

The TCPServer/Listener approach will be faster in that the reaction of the Listener code will nearly instantaneous to the receipt of the message (not that the FSW couldn't do this, but its just not as clean in my opinion). However, the TCP code is significantly more advanced (again, in my opinion) for a beginner than would be the XML file based approach.

I will say, though, if you do go with the XML file based approach you should try to upgrade your project to Studio 2008 if at all possible, to leverage LINQ and XML Literals.
 
thanks for your reply. I will stick with the TCPServer/Listener approach.

Do you have any sample code to send me or any example?

thanks again
 
is there anyone who can answer my question or give me a sample for a multithreading client/server program?

thanks in advance
 
As this seems to be an early app for you based on previous comments you will likely want to use the BackgroundWorker object, rather than true multithreading as it accomplishes many of the same things without as much hassle.

You can find a decent BGW example here: CodeGuru: Safe Multithreading with the BackgroundWorker Component and of course the MSDN pages on the topic are always helpful: BackgroundWorker Class (System.ComponentModel)

I should add, however, you are getting into some decently complex territory. Can you tell us anything else about the project or your goals that we might offer up alternative approaches?
 
thanks for your reply Raven65

I'm doing a simple chat application just for message exchanging. The chat should support up to 10 users. I have seen the things u posted. It seems quite harder that multithreading. I used to program in Java using socket programming . Is there any code u could give me for a multithreading client/server chat. I found some in google but they dont work.

thanks
 
UDP Send and Receive using threads in VB.NET!

CodeProject: A Chat Application Using Asynchronous UDP sockets. Free source code and programming help

CodeProject: UDP Send and Receive using threads in VB.NET. Free source code and programming help


A TCP Chat Application

CodeProject: A TCP Chat Application. Free source code and programming help


FULL CREDIT TO CodeProject for these great demos and source code!

All of these demos above are working 100% and they helped me to understand UDP and TCP clearly.

*Note: The UDP_Send_Receive demo will work from the .exe contained in the projects BIN folder. If you have XP it will probably run from within VB.NET but unfortunately both of my computers run VISTA.

I cant seem to grant proper permissions to the VSHOST.EXE and I have a current post in this forum as well on this issue!

http://www.vbdotnetforums.com/net-sockets/29544-weird-upd-problem.html
 
Last edited:
thanks for your reply

Is this a multithreading application. Can more than one client connect to the server and exchange messages?

thanks
 
Yes! If you notice there are 2 separate projects:

Send and Receive

If you start the ReceiveUPD project then open the project SendUPD multiple times and place the same IP address into all running SendUPD's you will see the ReceiveUPD getting all the data sent by them.


OH Yeah and by the way.If you open up more than one instance of ReceiveUPD and start the server, you will get an error saying that only one server can be run.

This is obviously normal and just proved to me it was working!
 
Back
Top