Sending messages with few fields between client and server?
I want to build a simple client/server model( TCP ) in linux with C, which do a sample job as:
Client send a HELLO message to server, Hello message contains 4 fields
field 1: identify field - with 11 characters, "thangnc". If the string server received is not match "thangnc", so server will discard this message, if matchs server display "thangnc".
field 2: with 32 bit, contains size of Hello message.
I think that analysis of that model should:
Client : i creat a message queue, i send a struct Hello message created to message queue,
then i use send( ) with parameter points to message queue.
Server: i creat a message queue, a sample Hello message like Client, i send Hello to the
queue, then listen( ) to connect from client, recv( ) from client, point socket used to
recv( ) to message queue.
After that, when i want to use information in Hello message i just point in
So, is this analysis right ? Or Wrong?
when i used this, i printf () "thangnc" in server, but many ugly charaters display, i can't see "thangnc".
What i have to do?