chat server ... help plz

hello everyone!
i have code written in c. it's about a chat server. i want to modify this code to make it able for chatters to send more lines of text each time. In this code a chatter can send only one line each time. how can i do it ?any idea? thanks in advance...


#define BUFFSIZE 256
#define INPUT_PROMPT "Input > "
#define RECEIVED_PROMPT "Received> "

int recvln(connection, char *, int); //recvln=recieve line
int readln(char *, int);

* Program: chatserver
* Purpose: wait for a connection from a chatclient & allow users to chat
* Usage: chatserver
main(int argc, char *argv[])
connection conn;
int len;
char buff[BUFFSIZE];

if (argc != 2) {
(void) fprintf(stderr, "usage: %s
", argv[0]);

(void) printf("Chat Server Waiting For Connection.

/* wait for a connection from a chatclient */

conn = await_contact((appnum) atoi(argv[1]));
if (conn < 0)

(void) printf("Chat Connection Established.

/* iterate, reading from the client and the local user */

while((len = recvln(conn, buff, BUFFSIZE)) > 0) {
(void) printf(RECEIVED_PROMPT);
(void) fflush(stdout);
(void) write(STDOUT_FILENO, buff, len);

/* send a line to the chatclient */

(void) printf(INPUT_PROMPT);
(void) fflush(stdout);
if ((len = readln(buff, BUFFSIZE)) < 1)
buff[len - 1] = '
(void) send(conn, buff, len, 0);

(void) send_eof(conn);
(void) printf("
Chat Connection Closed.

return 0;

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!