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
printpw(8)						      System Manager's Manual							printpw(8)

NAME
printpw - Outputs the contents of the password database SYNOPSIS
printpw [-acdgsu] FLAGS
Outputs all information. Use of this flag is the same as specifying all flags with -cdgsu. Outputs username and the comment string. Out- put username and the login directory. Outputs username and the group ID numerical value. Output username and the login shell. Output username and the UID numerical value. DESCRIPTION
The printpw command outputs the contents of the /etc/passwd database file in ASCII format to the standard output. When printpw is called with no option, all usernames in the database are output. The /etc/passwd database file is accessed through the standard library function getpwent. On secure systems that have changed this library function or on systems with Network Information Service (NIS) service installed, printpw produces the same information. When printpw is called in combination with any flag, one or more additional columns separated with : (colon) is output. EXAMPLES
To output the username, UID, and login directory of all users in the password database file, enter: /usr/sbin/acct/printpw -ud FILES
Specifies the command path The password database file. RELATED INFORMATION
Commands: acct(8) delim off printpw(8)