06-27-2011
Quote:
Originally Posted by
serpens11
Hello guys!
I had seen some posts at this forum talking about my problem, but maybe my scenario is a little different, and I want other solutions.
I saw users of this forums saying that the way to shared sockets is using UNIX Sockets, but this is the only way in my scenario?
My Scenario:
I have a process that is the server. Server accepts clients (sockets) and then call to fork. If two clients connects to my server, parent process will have two childs, and now is my problem, one of this child need to send a message to the another child.
First, I thinked that I could save fd socket in share memory, and then using this fd in another child I'll be able to send messages to another client, but doesn't works...
Any ideas?? Thanks!
PD: Sorry for my bad english
Hi,
you can use shared_memory IPC to share the sockets(any data) between the two processes via a unique key. Otherwise you can instead create threads when you serve a new request. Then you save the overhead of forking a new process.
Thanks,
Gaurav.
This User Gave Thanks to gaurav1086 For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I need to write a shell script which would take 2 arguments pid , userid. Then it should kill all the child process under it. If a child process is not killed then it should wait for 1 minute and should kill.
can anybody give me the idea to write it? (0 Replies)
Discussion started by: nani_g
0 Replies
2. Programming
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#define BUFF_SIZE 256
#define CHILDS 4
#define DATAFILE "Client_Files.txt"
void worker(int n);... (3 Replies)
Discussion started by: dlcpereira
3 Replies
3. Programming
hi, i want to write a code for forking 3 4 child. n wants that every child process one of the account from global account list. i wrote a program for that, but problem is every child is processing every account in list. what can me done to avoid it.
attaching code with it
#include <stdio.h>... (2 Replies)
Discussion started by: anup13
2 Replies
4. UNIX for Advanced & Expert Users
Hi,
I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime.
To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies
5. Programming
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
6. Linux
Hello every one i am implementing client server program.To handle multiple fds of client in server i used poll function.But this poll not able to access socket fd from other process.How can i share socket fd between two process.
Please Help me,Thanks in advance. (1 Reply)
Discussion started by: andrew.paul
1 Replies
7. Programming
Hello every one i am implementing client server program.To handle multiple fds of client in server i used poll function.But this poll not able to access socket fd from other process.How can i share socket fd between two process.
Please Help me,Thanks in advance. (3 Replies)
Discussion started by: andrew.paul
3 Replies
8. Programming
Hi gurus, I would like to fork more children and then write their return values: so far I tried:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(void)
{
pid_t pid;
int rv=0, i;
... (5 Replies)
Discussion started by: wakatana
5 Replies
9. IP Networking
I need clarification on whether it is okay to set socket options on a listening socket
simultaneously when it is being used in an accept() call?
Following is the scenario:-
-- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies
10. Programming
Hey guys,
I have to make a C program that simulates this command :
cat (files here) | sort > file.txt
So, I start and create a pipe. Then create the first child. This first child will execute the Cat through the pipe. Then create a second child that will execute sort, with input from... (4 Replies)
Discussion started by: Poppo
4 Replies
LEARN ABOUT DEBIAN
gcstar
GCSTAR(1) Linux User's Manual GCSTAR(1)
NAME
GCstar - Personal collection manager
SYNOPSIS
gcstar [-u UPDATE-OPTIONS] [-x EXECUTE-OPTIONS] [FILENAME]
DESCRIPTION
GCstar is a Gtk2 program used to manage personal collections.
OPTIONS
Without any option, it will open FILENAME if specified or the previously opened file. There are also two groups of options.
UPDATE-OPTIONS
-u, --update
Tell GCstar to look for available updates
-a, --all
Update all components
-c, --collection
Update collection models
-w, --website
Update plugins to download information
-i, --import
Update plugins to import data
-e, --export
Update plugins to export data
-l, --lang
Update translations
-n, --noproxy
Don't ask for a proxy
EXECUTE-OPTIONS
-x, --execute
Enter non-interactive mode
-c, --collection MODEL
Specify the collection type
-w, --website PLUGIN
Specify the plugin to use to download information
-i, --import PLUGIN
Specify the plugin to use to import a collection
-e, --export PLUGIN
Specify the plugin to use to export the collection
-f, --fields FILENAME
File containing fields list to use for import/export
-o, --output FILENAME
Write output in FILENAME instead of standard output
--download TITLE
Search for the item with TITLE as name
--importprefs PREFERENCES
Preferences for the import plugin
--exportprefs PREFERENCES
Preferences for the export plugin
Preferences for import/export plugins are specified using this schema
Key1=>Value1,Key2=>Value2
ENVIRONMENT
HOME Used to define following variables if needed
XDG_CONFIG_HOME
Where configuration files should be stored. If not defined: $HOME/.config
XDG_DATA_HOME
Where some data will be stored. If not defined: $HOME/.local/share
BUGS REPORTING
To report bugs, please use this forum:
http://forums.gcstar.org/viewforum.php?id=4
AUTHORS
Tian <tian@c-sait.net>
http://www.gcstar.org/
GCstar 17 August 2006 GCSTAR(1)