Sponsored Content
Top Forums Programming Two player game, forking & sockets Post 302528138 by Shang on Monday 6th of June 2011 01:05:50 PM
Old 06-06-2011
Two player game, forking & sockets

Hi.
I am just making first steps in Linux POSIX programming. I have read some tutorials on processes, signals and sockets (thanks Beej!), so some basic knowledge I have already got.
I want to write some very basic game server. My idea is to have main process, which is waiting for new players. If there are at least two clients connected, spawn one process per every player and then start doing some actions (not relevant now). Players (separate processes) would communicate in pairs through hm... I don't know yet, for sure some IPC structure.

According to this very general approach (I am just beginner Smilie) I have few questions:
1. How to provide proper waiting for players, for example when there is no clients at all or there is only one and waits for opponent?
2. How to handle three way inter-process communication? I mean between main process, player1 process, player3 process. I am guessing I would have to use some semaphores.
3. How to handle such communication, when the main process has to gather some information about paired clients moves and waiting for new clients at the same time? Can it be done in one, main process?
4. Could you explain me some basic algorithm how such program should be properly constructed? Some skeleton, names of functions, which manuals I have to study and general hints in order not to make steps blindly.

Thank you in advance.

Last edited by Shang; 06-06-2011 at 02:11 PM..
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Association b/w sockets & processes

Hi, Is there any way i can know the association between sockets and the processes which created them. :confused: (5 Replies)
Discussion started by: soorajmu
5 Replies

2. Linux

Having player problem && need your help.

My System is FC3, The following Players don't run well: 1).Helix Player couldn't play MP3 and *.wma files, 2).Totem is the same, 3)XMMS couldn't play .wma files. I am a newer of Linux,but I like Linux,just as you. Could you help me? Thank you! (1 Reply)
Discussion started by: letcorpmuv
1 Replies

3. 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

4. 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

5. HP-UX

Mozilla & Macromedia Flash Player Plugin Problem

Hello All, I am using Mozilla 1.7.8 on hp-ux 11.00, and install flash player 6 for it. it is giving following errors and get crashed. when i want to open a site need flash plugin. Gtk-WARNING **: invalid cast from `GtkSuperWin' to `GtkWidget' Gtk-WARNING **: invalid cast from `GtkSuperWin'... (1 Reply)
Discussion started by: Awadhesh
1 Replies

6. 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

7. 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

8. Linux

Unable to install VLC media player or any other player in SL 6.3 distro

Hi, I am unable to install VLC or any other media players in my SL 6.3 distro. I am using yum utility to install the packages, but i am getting the below error messages, --> Processing Dependency: libpng15.so.15()(64bit) for package: vlc-core-2.0.3-1.fc18.x86_64 --> Processing... (1 Reply)
Discussion started by: vel4ever
1 Replies
wait(1) 						      General Commands Manual							   wait(1)

NAME
wait - await process completion SYNOPSIS
[pid] DESCRIPTION
If no argument is specified, waits until all processes (started with of the current shell have completed, and reports on abnormal termina- tions. If a numeric argument pid is given and is the process ID of a background process, waits until that process has completed. Other- wise, if pid is not a background process, exits without waiting for any processes to complete. Because the system call must be executed in the parent process, the shell itself executes without creating a new process (see wait(2)). Command-Line Arguments supports the following command line arguments: The unsigned decimal integer process ID of a command, whose termination is to wait for. WARNINGS
Some processes in a 2-or-more-stage pipeline may not be children of the shell, and thus cannot be waited for. SEE ALSO
csh(1), ksh(1), sh-posix(1), sh(1), wait(2). STANDARDS CONFORMANCE
wait(1)
All times are GMT -4. The time now is 01:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy