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
GFTP(1) 						      General Commands Manual							   GFTP(1)

NAME
gftp - file transfer client for *NIX based machines. SYNOPSIS
gftp [options] [[proto://][ user : [pass] @] server [: port ][/ directory ]] DESCRIPTION
gFTP is a file transfer client for *NIX based machines. It currently has a text interface and a GTK+ 1.2/2.x graphical interface. It cur- rently supports the FTP, FTPS (control connection only), HTTP, HTTPS, SSH and FSP protocols. OPTIONS
You may enter a url on the command line that gFTP will automatically connect to when it starts up. --help, -h Display program usage. --info Display some information about how gFTP was built. Please send the output of this command when submitting a bug report. --version, -v Display the current version of gFTP. proto This specifies the protocol that should be used. It can currently be one of the following options: ftp, ftps, http, https, ssh, fsp, local and bookmark. If omitted, the protocol specified by the default_protocol option will be used. user The username that will be used to log into the remote server. If omitted, your current username will be used for most protocols. For the FTP protocol, the anonymous username will be used. pass The password that will be used to log into the remote server. If omitted, you will be prompted for the password. If you are using the FTP protocol, and the username is anonymous, then your email address will be used as the password. server The remote server to connect to. port The remote port on the server to connect to. If omitted, the default port for the protocol will be used. The port will be looked up in the services(5) file. directory The directory to change to once you are connected to the remote server. FILES
~/.gftp/gftprc Per user configuration file. Most of these options can be edited inside gFTP. This file is also commented very well. ~/.gftp/book- marks Per user bookmarks file. BUGS
If you find any bugs in gFTP, please report them to GNOME's Bugzilla at http://bugzilla.gnome.org/ AUTHOR
Brian Masney <masneyb@gftp.org> - http://www.gftp.org/ MARCH 2007 GFTP(1)