Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Shump

Pages: [1]
1
Network / Three general questions about networking in SFML
« on: January 20, 2009, 11:52:29 am »
Hi!
I'm working on a simple multiplayer game, a school project. The game is based on the server-client model and it is using both TCP and UPD for different connections. I started out doing a simple chat-program, consisting of a server program and a client program, and the result was quite successful. I can start the server program on one computer, connect with several clients which can send and receive both TCP and UDP messages.

However, I've got some basic features that I would like to implement. Firstly, is it possible to have both a client program and a server program running on the same computer? I'm new to network coding, but I think it has to be something with the ports you use. At present, both my client and server program are using two ports, one for TCP listening and sending and one for UDP listening and sending. Maybe it is possible to achieve the wanted effect by using different ports for listening and sending, so that the send socket at the client program is using the same port as the listening socket at the server program and vice versa.

Secondly, in most network programs (e.g. multiplayer games) it is only necessary to open the ports for the server program, not the client. Although, when I tried my program over internet (I've previously only tested on LAN) I needed to open up ports for my client as well. HAs this something to do with the fact that I'm using a selector in the client program as well (which is not necessary, however, abit easier)?

Lastly, I'm also thinking of how to detect when a client is detected. It can be easily done by letting the disconnecting client send a "goodbye"-message and then the server can remove it from the list containing connected clients. However, if the client just cuts its connection with the server (e.g. it crashes) the connection will not be closed properly and I've experienced that the selector's timeout-function goes crazy and behaves as if it's set on a very short time (like 0.0...01 seconds). Is it possible to have the TCP socket nature of a constant connection to tackle this problem (which is the reason why I've been using it in the first plce)?

2
System / General questions about mutexes and threading
« on: December 27, 2008, 08:33:49 pm »
Hi! I've got two questions about SFML's threads and mutexes.

First, a general question about sharing variables and objects between threads. Is it necessary to use mutexes to lock an object both when you're reading and writing to it or is it enough just locking it when you write to it. In other words, what happens if a thread is reading an object, that is not locked, and then another thread wants to lock and write to it? It seems much more efficient to just lock it only when you need to change it, otherwise, the program may end up spending more time locking and unlocking an object just to get read and write access to it.

My second question is about functions(and methods as well) and threads. What happens if a thread wants to use a function at the same time as another? Is it necessary and possible to use mutexes to lock and unlock access to functions aswell?

3
Graphics / Create alpha mask from B/W image
« on: May 14, 2008, 01:31:01 pm »
Is it possible to create an alpha mask from a black and white image source? Does it have anything with sprite's blendmode to do?

Pages: [1]
anything