So it is as the title says: a "client-server" type program. Basically the objective is that a client has to query a server (actually just two projects that are "talking" on port 8888 right now...) about some quotes that the server has stored in an array.
The client has three options to input in a text box: '1' displays a random quote, '2' displays all quotes present and '3' displays a command list (what I am typing right now).
I am pretty new to C# so I am having trouble grasping how a string can effectively be read in the server project FROM the client project. (I will parse to an integer after the server reads the "text" value)
Forgive me if I am missing anything important -- I will be happy to provide you with anything you'd need
THANKS!
C# client/server programming question?
Its kind of complicated but to answer...the server is basically waiting to receive prompts from a client. The server project is sitting there waiting for commands to be sent to it. Just like any other server ftp, telnet, ssh. The server project/daemon waits for the client to connect to the proper port, the client then sends a connect command or something similar to the server along with login information etc etc.
Reply:okay.. the commmands... those are interpreted by you to the server.. I assume you have some sort of database holding your quotes, right? Well if the user types a command like "g:3".. it's your duty to determine what that means.. perhaps "g" stands for "get" and the colon indicates a parameter is coming next.. and the input of 3 is for the third quote.. as far as I understand what you are doing this is basic manipulation of the database.. so you would have stored procedure calls and again you are the ones to make the mapping of commands to the server..
if i knew more of what these commands were supposed to do I could be more exact in WHAT you want to do..
--------
I pulled this out of the MS help on how to set up sqlcommands and connections.. I understand your 'server app' is a console.. but is it supposed to pull from a db or something?
Dim queryString As String = _
"SELECT OrderID, CustomerID FROM dbo.Orders;" '-- clearly have your own stored proc or line here..
Using connection As New Sql Connection(connectionString)
Dim command As New S qlCommand(queryString, connection)
connection.Open()
Dim reader As SqlDataReader = command.Exec uteReader()
Try
While reader.Read()
Console.WriteLine(String.Form at("{0}, {1}", _
reader(0), reader(1)))
End While
Finally
' Always call Close when done reading.
reader.Close()
End Try
End Using
Reply:The easiest method would be to simply use a web service to handle the client/server communication. Remoting will work as well, but I think you'll find the web service is a much easier route to take.
*******EDIT********
Do you want to use remoting or sockets?
Reply:What exactly is your program? Is it a web App? A windows app? Two console apps one for client and one for server? Need some more details.
Reply:You may contact a c# helper live at website
like http://gionram.com/
customer survey
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment