Note that there are some explanatory texts on larger screens.

plurals
  1. POApproaches to programming application-level protocols?
    primarykey
    data
    text
    <p>I'm doing some simple socket programming in C#. I am attempting to authenticate a user by reading the username and password from the client console, sending the credentials to the server, and returning the authentication status from the server. Basic stuff. My question is, how do I ensure that the data is in a format that both the server and client <em>expect</em>? </p> <p>For example, here's how I read the user credentials on the client:</p> <pre><code> Console.WriteLine("Enter username: "); string username = Console.ReadLine(); Console.WriteLine("Enter plassword: "); string password = Console.ReadLine(); StreamWriter clientSocketWriter = new StreamWriter(new NetworkStream(clientSocket)); clientSocketWriter.WriteLine(username + ":" + password); clientSocketWriter.Flush(); </code></pre> <p>Here I am delimiting the username and password with a colon (or some other symbol) on the client side. On the server I simply split the string using ":" as the token. This works, but it seems sort of... unsafe. Shouldn't there be some sort of delimiter token that is <em>shared</em> between client and server so I don't have to just hard-code it in like this?</p> <p>It's a similar matter for the server response. If the authentication is successful, how do I send a response back in a format that the client expects? Would I simply send a "SUCCESS" or "AuthSuccessful=True/False" string? How would I ensure the client knows what format the server sends data in (other than just hard-coding it into the client)? </p> <p>I guess what I am asking is how to design and implement an application-level protocol. I realize it is sort of unique to your application, but what is the typical approach that programmers generally use? Furthermore, how do you keep the format consistent? I would really appreciate some links to articles on this matter as well.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload