4 Replies - 186 Views - Last Post: 09 February 2012 - 12:54 PM Rate Topic: -----

Topic Sponsor:

#1 hellborg  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 52
  • Joined: 19-March 11

earmarked packets

Posted 07 February 2012 - 02:59 AM

my question is simple, i have started fiddling with tcpclient and listener and have succesfully created a chat client, but what i would like to know is, is there any way to earmark a packet that you are sending? as in if its earmarked login for example i want it to check if the username and password is correct.

i did get around this by making login the first thing that was being sent and using a bool to determine if it had been sent
if(login == true) {username = data}

something like that.

but i found this solution to be a bit ugly, so i was thinking if there is another solution :)
thank you in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: earmarked packets

#2 modi123_1  Icon User is offline

  • Suiter #2
  • member icon


Reputation: 3561
  • View blog
  • Posts: 14,989
  • Joined: 12-June 08

Re: earmarked packets

Posted 07 February 2012 - 08:16 AM

It seems you are sort of going the long way around the path here. why be concerned about if an individual packet is earmarked - why not provide a specific program flow based on what you set up...

First step after 'connect' is pressed it sends a specific login command and appropriate data.. if that works then continue making the connection.. if not then deny itl. The client and server should react to commands sent not individual packets. Let the data layer do what the data layer does... and focus on that application layer!
Was This Post Helpful? 0
  • +
  • -

#3 tlhIn`toq  Icon User is online

  • WillMyCodeWork = !FailedWhenYouTriedIt;
  • member icon

Reputation: 3290
  • View blog
  • Posts: 6,898
  • Joined: 02-June 10

Re: earmarked packets

Posted 07 February 2012 - 08:42 AM

I think you two are saying the same thing... but in different wording based on experience.

The user is asking "How do a I send the command: login with these credentials" or "How do I send the command: begin receiving file upload"... but the question is coming from their experience level, assuming they need to create a packet of data that somehow incases the command.

Hellborg: You say you have successfully created a chat program. Did you do that based on a tutorial, or all from scratch?
Client/server chat tutorial
Peer-to-peer chat
Was This Post Helpful? 0
  • +
  • -

#4 hellborg  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 52
  • Joined: 19-March 11

Re: earmarked packets

Posted 07 February 2012 - 11:51 PM

i did follow a tutorial, but i understand what i coded and then changed it from console to win form. but yeah, it is pretty basic
Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is online

  • WillMyCodeWork = !FailedWhenYouTriedIt;
  • member icon

Reputation: 3290
  • View blog
  • Posts: 6,898
  • Joined: 02-June 10

Re: earmarked packets

Posted 09 February 2012 - 12:54 PM

It kinda sounds like you want to create your own communication protocol.

So you're sending a byte[]..

123456789|123456789|123456789|

First 3 bytes are the type of packet
256^3 gives you a lot of packet types - planning ahead
001 = LogIn
002 = text message (chatting)
003 = file transfer
004 = Notification of status
...
bytes 4-10 subtype information
bytes 11-30 Description string
bytes 31-n big raw data byte[]

So if you send
0040000001 - That is status change to subtype 1 (available) and 11-30 might be the Status message: "Sitting around"

if you send
0020000[...] "So what are you doing this afternoon" the 002 tells you that the raw data (bytes 31 to end) contain all the text

if you send
001[...] then it is the login username/password in the raw data block


So its your protocol... make of it what you want.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1