Opinion please.

This is a discussion on Opinion please. within the Tech Board forums, part of the Community Boards category; I am making a client server app. I cant figure out a good protocol. I came up with the following ...

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    25

    Opinion please.

    I am making a client server app. I cant figure out a good protocol. I came up with the following packet for the signno process.



    Code:
    000000x1USERNAME00x2PASSWORD00x3CLIENT0000

    Broken down, it means:


    Code:
    0000 = packet start/end
    00x1 = username is coming Next
    USERNAME
    00x2 = password is coming Next
    PASSWORD
    00x3 = client verson is coming
    CLIENT VERSION
    0000 = packet start/end

    I was wondering what everyone thinks of this? Any susgesions? Thanks in advance!

    Kevin Carpenter
    Freelance Computer Programmer
    Thanks

  2. #2
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    probly better in c++ section.

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    25
    I'm not asking a C++ question, I'm asking a general programming question
    Thanks

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by Carp
    I'm not asking a C++ question, I'm asking a general programming question
    General Discussions
    Non-programming related topics

  5. #5
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    You need to include message/field lengths. That way you can avoid classic problems such as "what happens if the password contain 00x3?".

    I'd suggest something like this (this is only a guide, adapt it as you see fit):
    Code:
    AAABCCC...
    
    Where AAA is a message length indicator (always 3 bytes, padded with leading zeros), 
    B is the message type indicator, 
    and C is the message.
    
    Eg
    
    007UHAMMER009PSeCuRiTy
    
    007 - 7 bytes of data coming up next
    U - User id follows
    HAMMER - the user (duh!)
    009 - 9 bytes of data coming up next
    P - Password follows
    SeCuRiTy - the password.
    It's important to use a length indicator, as socket input to your program will appear as a stream of data. One call to recv() isn't going to get you one complete message. If you want to know more, ask (or read a TCP/IP programmers book/reference)

    Of course, you may want to consider some form of encryption if you're sending passwords over a socket.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Her opinion, your opinion
    By RoD in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2002, 09:50 AM
  2. A matter of opinion
    By pepperblue255 in forum C++ Programming
    Replies: 2
    Last Post: 10-05-2002, 09:51 PM
  3. Freedom of opinion
    By Shiro in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 02-10-2002, 06:06 AM
  4. opinion about books
    By clement in forum C Programming
    Replies: 7
    Last Post: 09-24-2001, 04:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21