forking for multiple clients


 
Thread Tools Search this Thread
Top Forums Programming forking for multiple clients
# 1  
Old 06-18-2011
forking for multiple clients

hello everyone,
i am making a tcp chat server using c in linux. i have used socket programming to connect the server and the client.
can anyone please let me know how i can use forking for multiple clients??
thank you
# 2  
Old 06-19-2011
You usually fork() after the accept(); in the child you close the listening socket and continue the processing with the connected socket returned by accept(); while in the parent you close the connected socket and call accept() again.

You need to handle the termination of the children in the parent process; otherwise you'll get zombie processes hanging around.

HTH, Loïc
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Samba with clients in multiple domains

Dear all, I've not a good starting point I'm afraid, but I was forced to deploy Samba under pressure of failing hardware so an urgent migration was done. We didn't get the IBM AIX 6.1 supplied one running at all, so we pulled down the samba.org version 3.4.3. We couldn't get that working as... (0 Replies)
Discussion started by: rbatte1
0 Replies

2. Programming

need help in forking

I have an input file with contents like: 5785690|68690|898809 7960789|89709|789789 7669900|87865|659708 7869098|65769|347658 so on.. I need to pass this file to 10 parallely running processes (forking)so that each line is processed by a process and no line is processed twice and write the... (1 Reply)
Discussion started by: rkrish
1 Replies

3. Solaris

Jumpstart Multiple Clients

We have a WAN boot jumpstart server which works fine .. we have a requirement wherein we would require to jumpstart multiple sparc servers simultaneously, Whats the way .. so that we do not have to wait for a cleint to complete the installation before starting with another server. Any help would... (1 Reply)
Discussion started by: fugitive
1 Replies

4. Programming

Need help with fork, forking multiple childs and shared memory

Hi all, I m writing an application, where i need to fork multiple childs and those child should handle particular task given to them. More descriptive. For example, suppose i have 4 Network, each network has multiple nodes. Now on the basis of network child should be forked and these child... (8 Replies)
Discussion started by: helpmeforlinux
8 Replies

5. Programming

socket programming (UDP with multiple clients)

Hi all, I have an application where there are 5 udp clients/senders which keep sending data to same IP with different port number can I design my udp server to recieve data from all 5 clients at the same time? how should I use the server address structure? should I use different... (3 Replies)
Discussion started by: shashi
3 Replies

6. UNIX for Dummies Questions & Answers

Looking for an X11 Utility - Send Keystrokes to Multiple Clients

A long time ago, I frequently used a small X11 utility that allows you to manage multiple systems at the same time. It worked by opening a small window that had a button you used to "Add" X Clients to it. These would be xterms on different systems for example. You would then type inside that... (5 Replies)
Discussion started by: Alon.Albert
5 Replies

7. Programming

forking within a thread

Is it safe to call fork+exec in a multithreaded application. Because In my multithreaded application, I need to execute another program in each thread. I am using solaris 10. Any suggestions pls. (2 Replies)
Discussion started by: axes
2 Replies

8. Programming

forking process.

#include <stdio.h> #include <sys/types.h> #include <unistd.h> int main() { pid_t pID; int i; for (i = 0; i < 3; i++) { pID = fork (); if (pID == 0) { printf ("Value of i --> %d... (2 Replies)
Discussion started by: kymthasneem
2 Replies

9. UNIX for Advanced & Expert Users

Forking

When I compile this C programme I get different outputs each time I run it Please explain to me whats happening in the code if you can give me a detailed explanation with the schedular functionality it will help a lot. Because I am stuck with this. #include <stdio.h> main(){... (3 Replies)
Discussion started by: manjuWicky
3 Replies

10. Programming

Forking in a loop

When I compile this C programme I get different outputs each time I run it Please explain to me whats happening in the code if you can give me a detailed explanation. Because I am stuck with this. #include <stdio.h> main(){ int i = 0; printf("I am the... (1 Reply)
Discussion started by: manjuWicky
1 Replies
Login or Register to Ask a Question