Handling Multiple terminals


 
Thread Tools Search this Thread
Top Forums Programming Handling Multiple terminals
# 1  
Old 03-25-2010
Handling Multiple terminals

Hi,
Basically I've written a game in ncurses that supports multiple players. Each player has a process associated with him which shares a segment of memory in which the player's structures are stored, and these structured are accessed by the 'server' program and handled there. The scope of the program is that when a user wants to access a game that has already started he can do so from his terminal, and the 'server' process will simply fork a child process to handle his input and start communicating with it. I am having problems implementing this. Is there a way to have the server listen for commands that can come from a seperate terminal such that when this command is invoked it performs a specific routine ? Thanks. Any help will be appreciated.
# 2  
Old 03-25-2010
This is mostly a networking problem. How familiar are you with TCP networking? You could also do this through UNIX domain sockets but you could just as easily substitute TCP sockets and get a game server that can work over the internet. Smilie

The jist of it is, have a thread in your server waiting for connections such that, when accept() returns, the server forks off a new process to handle the new connection.
# 3  
Old 03-25-2010
If you have shared memory, why does the server need to handle the input?

The client process writes and reads shared memory. What else is needed?
# 4  
Old 03-25-2010
Quote:
Originally Posted by TonyLawrence
If you have shared memory, why does the server need to handle the input?

The client process writes and reads shared memory. What else is needed?
Correct me if I'm wrong but it sounds to me like the shared memory is all part of the server and not relevant to the clients. The server forks off its own processes to handle the game space.

[edit] Yeah, I was wrong. Let me rethink this.

---------- Post updated at 12:32 PM ---------- Previous update was at 12:28 PM ----------

Okay, so the clients are already sharing memory.

1) How are you mutexing this? Are you mutexing this?
2) Lots and lots of ways to handle server-client communication, but shoehorning that into the shared mem would just be building your own ad-hoc sockets. Might as well use real sockets.
# 5  
Old 03-25-2010
Re

Hey guys thanks for your interest. The server program initializes game character structures and stores them in shared memory. The client side process listens for user input and modifies the game character structures accordingly. On changes to the character structures the server does some graphical handling to indicate these changes to the user. What I need is a means for the client side program to connect to a server side program which is already running in order for the server side program to run a method that initializes a character structure in shared memory and spawns off a user process to listen for input from the terminal that the user 'connected' from.

---------- Post updated at 01:35 PM ---------- Previous update was at 01:34 PM ----------

btw..all users that could possibly connect to the game are gonna be running on the same machine but different terminals...just in case you find it relevant
# 6  
Old 03-25-2010
What do you mean by 'terminal'? Do you mean that literally -- the server has to take over the client's terminal device? Or do you just mean the server has to listen for input from the client process?

How are you mutexing the shared memory? Are you mutexing the shared memory?

Lots and lots of ways to handle server-client communication, but shoehorning that into the shared mem would just be building your own ad-hoc sockets. Might as well use real sockets.
# 7  
Old 03-25-2010
the clients terminal device must cause the 'server' process to register it within the server process and initialize a shared memory segment. I don't see the need for mutexing as the shared memory segment is being modified by only one process and read by only process also. Hence no corrupt data can occur. I was hoping to implement this without the use of sockets.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using getopts for handling multiple options

Hi Guys, I have created a script for our automated DB creation, it works fine with default option(-d). $ ./test_db.ksh -d abc 11 dev -d is Default option ORACLE_SID=abc ORACLE_VERSION=11 ENV_TYPE=dev For creating a customized DB, i thought of giving the user different options.... (8 Replies)
Discussion started by: veeresh_15
8 Replies

2. Shell Programming and Scripting

Automate an application using scripting, managing multiple terminals

Hi I am new to Ubuntu and Bash scripting. I am working on a project to give a demo on an SDN application to my class. I need some help in scripting to create the demo. Please help in case if you have any idea on what am asking. The demo uses a tool called mininet. I need just one script so... (2 Replies)
Discussion started by: anzal
2 Replies

3. Shell Programming and Scripting

ISSUE in handling multiple same name files :-(

Dear all, My work is completely stuck cos of the following issue. Please find it here and kindly help me. Task is following: I have set of files with such pattern 1t-rw-rw-r-- 1 emily emily 119 Jun 11 10:45 vgtree_5_1_pfs.root 3t-rw-rw-r-- 1 emily emily 145 Jun 11 10:46 vgtree_5_3_pfs.root... (4 Replies)
Discussion started by: emily
4 Replies

4. Shell Programming and Scripting

Help with Handling multiple argument in shell script

Hi i have written a shell script that takes only single ip address from the user and calculates its latency and reliability, can you please tell me that what should be done if i want that user should enter 100 or 1000 ip address (5 Replies)
Discussion started by: Preeti_17
5 Replies

5. AIX

How to open multiple virtual terminals to a single LPAR

I just wondering if there are ways to open multiple virtual terminal to a single LPAR. After I have use putty to login to the VIOS. I will use mkvt -id <LPAR id> to open console but if my friend want to open 2 second one, it will say, VT already connected. IS there a way to work this around ? ... (1 Reply)
Discussion started by: wingcross
1 Replies

6. Shell Programming and Scripting

running Multiple terminals/shells

Hi, I'm looking for a way to send commands through multiple shells/terminals (not sure which is proper syntax). Basically, I have to open 3 different shells/terminals and run separate parts of a program suite in each of them. I find this annoying. The commands I have to do are simple, and could... (1 Reply)
Discussion started by: Caradoc
1 Replies

7. Shell Programming and Scripting

calling multiple terminals

I'd like to write a script that will call n number of terminals that will all ssh to X-server and automatically enter the same password. Unfortunately I'm not exactly sure what kind of commands would work for me here because when I call for gnome-terminal, a new terminal pops up and the old... (1 Reply)
Discussion started by: gelitini
1 Replies

8. UNIX for Advanced & Expert Users

Multiple file handling

Dear All, I have two files, which looks like: File 1 124 235 152 178 156 142 178 163 159 File 2 124|5623 452|6698 178|9995 (8 Replies)
Discussion started by: rochitsharma
8 Replies

9. UNIX for Advanced & Expert Users

Multiple Terminals

Dear Members, I have aquired a load of old Wyse dumb terminals. I have a Linux system set up that I want to be the host for all of these. Now, I know these don't use cat5 or standard networking. They are all done through serial (com) ports. However, I researched this more and found a converter... (25 Replies)
Discussion started by: Phobos
25 Replies
Login or Register to Ask a Question