I am making a game client for Ragnarok Online. The Server is actually made up of 3 Programs each running on a different Port. I am Currently Using 3 different sockets to handle the 3 different servers, but Im pretty sure that It could be done with 1 socket. What would you do?
I would use an array of sockets.
I thought of that solution myself as well, A good Idea, but I hate passing around the stupid index of the socket.
I agree with rabbit, arrays are the best way to go when you want to work with multiple sockets (or other classes) and have easy access to them.
afaik just create a new instance of the object by refrencing it
If it uses UDP you could possibly use one socket
That's true, but from the way he described it it sounded like TCP, so that's what I went with.
Heres how things work
I connect to server 1, talk to it a bit, get a message that i then use to connect to server 2, talk with server 2 then get a message that i use to connect with server 3 from which I sustain my connection with., I dont need to be connected to all the servers at the same time at all.
Looks to me like you only need to maintain one connection at any given time.
In which case you could simply use 1 socket and not have to deal with multiple controls or the passing of an index variable.