Thread: Sending messages with few fields between client and server?

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    2

    Lightbulb Sending messages with few fields between client and server?

    Hi,

    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
    message queue.

    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?

  2. #2
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Posting your code would be much more useful than giving a generic description.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    2
    thanks man, i solved this problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client/server problem; server either stops receiving data or client stops sending
    By robot-ic in forum Networking/Device Communication
    Replies: 10
    Last Post: 02-16-2009, 11:45 AM
  2. Replies: 2
    Last Post: 07-24-2008, 06:05 AM
  3. Socket Programming Problem!!!!
    By bobthebullet990 in forum Networking/Device Communication
    Replies: 2
    Last Post: 02-21-2008, 07:36 PM
  4. Where's the EPIPE signal?
    By marc.andrysco in forum Networking/Device Communication
    Replies: 0
    Last Post: 12-23-2006, 08:04 PM
  5. Unicode vurses Non Unicode client server application with winsock2 query?
    By dp_76 in forum Networking/Device Communication
    Replies: 0
    Last Post: 05-16-2005, 07:26 AM