Thread: C networking programming question

  1. #1
    Registered User
    Join Date
    Jan 2015
    Posts
    15

    C networking programming question

    So I've been reading the Beej's guide to network programming lately and have this question.. I'd like to get the server.c and client.c they show to have this functionality when run:

    1. Send message
    2. Receive message
    3. Quit

    so once the client connects to the server i want both the client and server to have this menu displayed with both options available for a real 2 way communication over the same socket. the data can be sent and stored as a file on the remote system or just displayed on the screen (thats easy to do) but my question is what about what I'm asking .. is that possible? or do i need to create 2 serverers and 2 clients and run them on 2 ports? thanks

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,436
    A socket, once established, is a 2-way communication link.

    The idea of 'client' and 'server' is really just about who phones who to establish the connection.
    Once connected, they're communication peers.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2015
    Posts
    15
    so the server doesn't *have* to stay in a listenning mode all the time? it can accept input from the keyboard and send it while receiving data on hte same socket? would i need something like ncurses to accomplish this?

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,436
    The 'listening' socket is distinct from the 'connected' socket.

    After a successful connection, the server has two open sockets.

    I suggest you look up the select() system call to allow you to monitor activity on a set of sockets and "do the right thing" when each socket indicates there is something to do.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jan 2015
    Posts
    15
    ok thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. networking question
    By geek@02 in forum Tech Board
    Replies: 15
    Last Post: 02-28-2008, 05:09 PM
  2. Networking Question Help
    By cplusplus.Jr in forum Networking/Device Communication
    Replies: 1
    Last Post: 04-15-2007, 02:18 AM
  3. Question about networking
    By chad101 in forum Networking/Device Communication
    Replies: 3
    Last Post: 10-12-2005, 07:21 AM
  4. Window Programming/Networking.
    By Coder87C in forum Windows Programming
    Replies: 1
    Last Post: 07-21-2005, 09:13 PM
  5. Networking question.
    By MethodMan in forum Tech Board
    Replies: 9
    Last Post: 09-03-2002, 10:50 AM

Tags for this Thread