Thread: Small Client Question

  1. #1

    Small Client Question

    Hello,

    I have done a board search, but I can't seem to find a simple answer to my question. I've even read Beej's document, though I did not see anything that could answer my question.

    Firstly, to lay a foundation, I've been working on a multi-client echo server for Linux. Now, that I have done that successfuly, I want to make a semi-chat style program. Everything is working as planned, except for the client.

    My client works along this concept:
    • Connect to server
    • Start infinite loop
    • -- Send data
    • -- Read data
    • Close socket

    The problem is that with my loop, I have to send data in order for it to receive data. This was more on the lines of an echo server, but I'm at a loss of how I would read data from the server when new information was sent, but still send data back accordingly. How should my client's concept be?


    - Stack Overflow
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Use select() to see if anything is avialable of that socket to be read.

  3. #3
    Alright,

    I'll take a look into that. Thanks again.


    - Stack Overflow
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Socket Programming Problem!!!!
    By bobthebullet990 in forum Networking/Device Communication
    Replies: 2
    Last Post: 02-21-2008, 07:36 PM
  2. programming job: small email client
    By calgonite in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 01-27-2006, 11:26 AM
  3. Small question about gets
    By Ash1981 in forum C Programming
    Replies: 4
    Last Post: 01-03-2006, 07:36 AM
  4. New to C, small compiler question
    By Ash1981 in forum C Programming
    Replies: 14
    Last Post: 12-31-2005, 02:16 AM
  5. A small Question
    By CodeJerk in forum C++ Programming
    Replies: 2
    Last Post: 11-20-2002, 09:08 AM