Programmer_to_be
asked on
CLIENT/SERVER app, send string data to server
Dear Experts;
i need to create a client/server application. the server must always be listening, the client(s) will send string data to it, the server will then store the data in a database.
with my experience with client/server applications, theyve always been unreliable for me. i mean that i could never get client/server communication to actually work, maybe because im behind a router. can someone show me how to make a reliable very simple client server app.
so the server must always be waiting, the client connects and sends a string to the server, once the server recieves this, it will store it in a database.
i actually need to send an array of strings (like first name, surname) etc, would i need to send the strings individually? or can i just send the whole array, then iterate through that array on the server side?
Thanks
i need to create a client/server application. the server must always be listening, the client(s) will send string data to it, the server will then store the data in a database.
with my experience with client/server applications, theyve always been unreliable for me. i mean that i could never get client/server communication to actually work, maybe because im behind a router. can someone show me how to make a reliable very simple client server app.
so the server must always be waiting, the client connects and sends a string to the server, once the server recieves this, it will store it in a database.
i actually need to send an array of strings (like first name, surname) etc, would i need to send the strings individually? or can i just send the whole array, then iterate through that array on the server side?
Thanks
Check out
http://www.codeproject.com/csharp/socketsincs.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconUsingNon-BlockingServerSocket.asp
and
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconUsingNon-BlockingServerSocket.asp
The two last ones are articles from Microsoft on asynchrounous server and client sockets, with links to sample code on the bottom.
If you do a google search on "asynchrounous server socket" or search for the same on sites like www.codeproject.com or www.codeguru.com you should find more articles and samples for the same.
http://www.codeproject.com/csharp/socketsincs.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconUsingNon-BlockingServerSocket.asp
and
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconUsingNon-BlockingServerSocket.asp
The two last ones are articles from Microsoft on asynchrounous server and client sockets, with links to sample code on the bottom.
If you do a google search on "asynchrounous server socket" or search for the same on sites like www.codeproject.com or www.codeguru.com you should find more articles and samples for the same.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the responses.
To further explain the situation, I am trying to create a form where users can register to my application, i.e. they send data such as first name, last name (or just a name field) and a password.
This data will then be stored on the server database.
Should I grab this data and send it over TCP as a comma delimited string? Or will I need to send them as individual packets/requests?
Would web services be a good option for this?
To further explain the situation, I am trying to create a form where users can register to my application, i.e. they send data such as first name, last name (or just a name field) and a password.
This data will then be stored on the server database.
Should I grab this data and send it over TCP as a comma delimited string? Or will I need to send them as individual packets/requests?
Would web services be a good option for this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks alaran and mogalmanic, you both have been VERY VERY helpful. Really appreciated it.
And to your question about sending it over TCP. In that case you should define for yourself a format of communication. F.ex. start all data transfers with a couple of bytes denoting how long the data you're sending is, so the server can know when it's got it all. Then choose an encoding for the text, and also a way of separating the different parts of data sent. This could be a comma delimited string, or pretty much whatever you like.
But as I said, web services provide a way easier way of doing this. There are a lot of pitfals to server/client programming which you don't have to worry about when using web services or remoting.
But as I said, web services provide a way easier way of doing this. There are a lot of pitfals to server/client programming which you don't have to worry about when using web services or remoting.
ASKER
alaran, thanks again, very helpful information. im just looking at a web service tutorial now and it seems very easy. thanks again. :-)
ASKER