Sponsored Content
Top Forums Programming Trouble with pipes in chat client on linux Post 302718395 by expl on Friday 19th of October 2012 02:14:12 PM
Old 10-19-2012
Well your code is pretty messy, Id sugest you start from 0 with a better design.
There are plenty of uncontrolled stuff happening specially with string buffer handling like so:

Code:
char buf[2] = {0}, message[999] = {0}

...

if((nret = recv(theSocket, message, 999, 0)) < 1)

...

memset(message, 0, strlen(message));

After the recv() call there is no way to make sure that 'message' is a proper 0 terminated string, so strlen() can go outside the buffer size and cause some weird stuff to happen after memset() runs. But this is probably not the major cause of problem for you.

Your client probably is not working because the parent process (childpid != 0) calls exit() before waiting for the child to clean up. If parent exits while child is still running kernel will send SIGINT to your child that will cause premature termination of it. You either need to call wait() function on the child or implement a better design.

Last edited by expl; 10-19-2012 at 03:24 PM.. Reason: typo
 

10 More Discussions You Might Find Interesting

1. Programming

multiuser chat server closes when one client closes. code included

I have been trying to write a very basic chat program but at the moment I am having problems getting it to be multiuser as it closes all connections when one client shutsdown. I have also been having problems trying to get the program to display a list of usernames to the clients. I have tried... (0 Replies)
Discussion started by: dooker
0 Replies

2. Programming

Chat client-server program

Good day everyone, I'm doing a chat client-server program:server is to receive messages from clients through a TCP port and multicast them back to all clients through a UDP port. This is my client program. I'd not know why it just sends and receives msg from server once, then it stops. Is... (1 Reply)
Discussion started by: powermind
1 Replies

3. Programming

client /server pipes

here is the concept: the client reads a pathname from the standard input and writes it to pipe1.The server reads this pathname from the pipe1 and tries to open the file for reading.If the server can open the file ,the server responds by reading the file and writting it to pipe2;otherwise the... (2 Replies)
Discussion started by: tolkki
2 Replies

4. UNIX for Dummies Questions & Answers

Server/client chat

I want to make the following programm. Using the server/client model I want 2 client to connect to the server then the server sends back to the clients the ip address and a number of a poort in order to open a udp connection between clients without using the server? What I have done since now is... (2 Replies)
Discussion started by: kasma
2 Replies

5. Programming

How can i make two client to chat with each other?

How can i make two client to chat with each other.. without any work of server, i mean peer to peer i am making chat messenger on which all host will connect to/via server and if any host want private chat then thay work independently... this is code(attached) which i have made for server... (1 Reply)
Discussion started by: bt87
1 Replies

6. UNIX for Dummies Questions & Answers

Server-client chat with a bit more

The task is to create a server client chat that contains a few basic safeguards against floods etc and which is capable of issuing at least one or two commands on the client computer. Working samples of such arrangements abound but freeware/shareware samples are not readily available. A catch in... (3 Replies)
Discussion started by: Bobby
3 Replies

7. Homework & Coursework Questions

Help with server client chat system

request create a chat system in linux where a user type smth and all the other users connected to server get the message.then a user have to create join leave or delete a channel of chat if he created it.i did the server and the client but i dont know how to implemt the chat rooms.i was ... (1 Reply)
Discussion started by: demonmind
1 Replies

8. Programming

please help a problem in client-server ipc message 2 pipes communication simple example

I want to have a message send & receive through 2 half-duplex pipes Flow of data top half pipe stdin--->parent(client) fd1--->pipe1-->child(server) fd1 bottom half pipe child(server) fd2---->pipe2--->parent(client) fd2--->stdout I need to have boundary structed message... (1 Reply)
Discussion started by: ouou
1 Replies

9. Programming

logic understanding for inter client chat server

hello everyone, i am making chat server in linux using c. i have made programs in which group chat can take place between multiple clients but i am not able to understand how to make 2 particular clients chat with each other. please help!!! (1 Reply)
Discussion started by: sweetbella
1 Replies

10. UNIX for Advanced & Expert Users

Linux chat with other users

Besides talk and write are there any other good programs for talking to a particular user on the same Linux system. (1 Reply)
Discussion started by: cokedude
1 Replies
Net::Hotline::PrivateChat(3pm)				User Contributed Perl Documentation			    Net::Hotline::PrivateChat(3pm)

NAME
Net::Hotline::PrivateChat - Private chat object used internally by Net::Hotline::Client SYNOPSIS
use Net::Hotline::PrivateChat; $pchat = new Net::Hotline::PrivateChat; $pchat->subject("Issue 1: Monkey beards"); $pchat->reference(0x313337); ... DESCRIPTION
Net::Hotline::PrivateChat is a simple class for storing and retrieving private chat information, You should never have to create your own Net::Hotline::PrivateChat objects when using Net::Hotline::Client. Getting and (to a lesser extent) setting attributes is all that should be necessary. CONSTRUCTION
new REF, USERLIST, SUBJECT Creates a new Net::Hotline::PrivateChat object with the reference REF, userlist USERLIST, and subject SUBJECT, where REF is a number, USERLIST is a reference to a hash of Net::Hotline::User objects keyed by socket number, and SUBJECT is a string. Any missing arguments will be set to undef. METHODS
All the Net::Hotline::PrivateChat methods are simple attribute get/set routines. If given an argument, they set an attribute. In all cases, they return the current value of the attribute. reference NUM The private chat reference number. subject TEXT The subject of the private chat. userlist HASHREF The list of users in the private chat. AUTHOR
John C. Siracusa (siracusa@mindspring.com) COPYRIGHT
Copyright(c) 1999 by John Siracusa. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2002-11-27 Net::Hotline::PrivateChat(3pm)
All times are GMT -4. The time now is 04:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy