How to encapsulate this ?


 
Thread Tools Search this Thread
Top Forums Programming How to encapsulate this ?
# 1  
Old 11-14-2006
How to encapsulate this ?

Hello !

I have a pretty question.I am working on a client-server chat aplication for Linux shell's.

When a user connect , is receives a window for the username . It has to enter the username, which will be used for future chat and private message ( + other option's ). I'm using socket's for network connection.

The point is , after a user is connect to server socket , the user has to enter a username . The problem here comes like that. Where does the chat server knew , if the username string is an ordinary string , used for chat , or the username string itself ?

I figure to do , some easy encaspulation.When the client connect , and receive username window , the username string is encapsulated with , let's say "***" at the end .

Let's say user !_30 is connected . First the client sends "!_30***" to server , the server dencapsulate those 3 '***' , and knows client username.

The problem here is that , when a user accidentaly send's "***" in main chat , whole sistem is doomed . The server sees "***" at the end .. of ( nothing ) and think's a new user is connected to the server.

How can I make this encapsulation/dencapsulation , transparent to send proces , not altering the string , and be doomed like up ..?

Any idea's , raw socket's ? Because the idea I mention is the only one that came , in that moment in my head .


Any ideas , is apreciate ! Cheer's ! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question
SPACEWALK-CHANNEL(8)						   Red Hat, Inc.					      SPACEWALK-CHANNEL(8)

NAME
spacewalk-channel - Subscribe to or unsubscribe system from channel. SYNOPSIS
spacewalk-channel [options] DESCRIPTION
spacewalk-channel allows you to subscribe to and unsubscribe from specified channels via the command line. A visit to the Red Hat Network (or Spacewalk) website isn't required. OPTIONS
-l, --list Print a list of channel(s) that you are currently subscribed to. -L, --available-channels Print a list of all available child channels. -a, --add You are subscribing system to given channel(s). You have to specify --user and --password. -r, --remove You are unsubscribing system to given channel(s). You have to specify --user and --password. -u, --user Your username used to register the system with and for Red Hat Network, RHN Satellite or Spacewalk. If you do not enter this option and it is required, you will be prompted. -p, --password The password associated with the username specified with the --user option. This is an unencrypted password. If you do not enter this option and it is required, you will be prompted. -c, --channel Label of channel you want to subscribe to or unsubscribe from. Can be specified multiple times. -v, --verbose Print out successfull action. -h, --help Show a help message and exit. NOTE
The addition and removal of channels is mutually exclusive, please use the command twice. EXAMPLES
Subscribe to two channels: spacewalk-channel --add -c rhn-tools-rhel-i386-server-5 -c rhel-i386-server-vt-5 --user username --password password Unsubscribe from channel: spacewalk-channel --remove -c rhn-tools-rhel-i386-server-5 -c rhel-i386-server-vt-5 --user username --password password List subscribed channels: spacewalk-channel --list SEE ALSO
rhnplugin(8), rhn_register(8), up2date(5). AUTHORS
Miroslav Suchy <msuchy@redhat.com> BUGS
Report bugs to <http://bugzilla.redhat.com>. COPYRIGHT
Copyright (C) 2009-2010 Red Hat, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. Linux 2010 August 30 SPACEWALK-CHANNEL(8)