Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Network programming, client-server interaction with multiple clients
Old 01-02-2013, 02:59 PM Network programming, client-server interaction with multiple clients
lizciz's Avatar
Super Spam Talker

Posts: 845
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Greetings.

I'm developing a small card game, based on a client-server solution. I have only touched lighly on network programming previously, covering the basics, and have now come across a few questions. Perhaps you can help me sort them out.

I'm developing this in C#, becuase I want to learn a new language, although I'm not looking for any language specific answers or code examples. Rather, my questions is more about the general client-server interaction, and how to handle multiple clients.

Currently, I've made a server which can be connected to by multiple clients (there is still no client though, I've been testing using telnet), after which it asks for a username and stores the connected user in a list. The idea is that the client, while in this "lounge area" (in lack of a better description) should be able to see all connected users and available games. A game can then either be joined or the client can create a new game and let others join that.

Questions:

1. Each client needs an updated list of available games and players. Should the client periodically ask the server for this, or should the server supply it upon connection and keep sending updates as the list changes?

2. The server needs to be able to remove inactive connections/clients (e.g. if a client crashes), but how can it keep track of them? Should the server periodically ask each client weather they're still alive or not, or should the client periodically announce that it is still alive, in which case the server assumes they're dead if they do not? Or is there another way?

3. Regarding both question 1 and 2, if the server is to periodically send data to all clients, is there any smarter way of doing so than to just loop through them all and send the same data through all sockets? That seems a bit ineffective to me. Sure, it won't matter unless there is alot of clients, but what if there is?


And I could swear there was something more I wanted to ask, but I can't recall what. Oh, well.

I'll be thankful for any help you can provide.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
 
Register now for full access!
Old 01-03-2013, 04:55 AM Re: Network programming, client-server interaction with multiple clients
chrishirst's Avatar
Defies a Status

Posts: 43,947
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Answers

1. Depends on the protocol used, for example HTTP is a disconnected protocol so only responds to client requests and the client has to send 'keep-alive' pings to maintain the connection.

Quote:
is there any smarter way of doing so than to just loop through them all and send the same data through all sockets?
Read up on multicasting and broadcasting

Telnet is too primitive being only 8bit. Like ICMP it is fine for 'playing with' and learning how to handle client/server communications and messaging, but for interactive gameplay, it doesn't stand a chance.

Taking SOAP as your starting point would be my suggestion
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-03-2013, 09:00 AM Re: Network programming, client-server interaction with multiple clients
lizciz's Avatar
Super Spam Talker

Posts: 845
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Hmm. I read up on SOAP, because I'd never heard of it before, and have been experimenting with it for a hour and a half. It seems very promising!

Originally I wasn't planning on using any existing protocol, since the program will only need to send/recieve a couple of simple commands. I thought I'd make my own, very simple, text based protocol. E.g. in its current state, when a client connects to the server, the server asks the client for a username with the string "u?", and the client replies with "U;username". Although that approach would probably yield less network traffic, it would require more manual work. SOAP simplifies things alot, and will likely be more reliable in the end.

I'll keep playing around with this for a while and post back if any new questions arise.
Thanks.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 05-04-2013, 06:59 PM Re: Network programming, client-server interaction with multiple clients
webspace's Avatar
Super Spam Talker

Posts: 938
Name: Buck Roberts
Location: Nampa, Idaho, United States
Trades: 0
Being the lousey coder that I am I have managed to code some client server stuff in java. There are tons of sockets progamming tutorials on youtube.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
blog about paintings, drawings and photographs.

Please login or register to view this content. Registration is FREE
Weapons system and aerospace components
webspace is offline
Reply With Quote
View Public Profile Visit webspace's homepage!
 
Reply     « Reply to Network programming, client-server interaction with multiple clients
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15136 seconds with 11 queries