Transfering to another port.
by Matthew Shapiro · in Technical Issues · 02/06/2002 (9:31 am) · 4 replies
In winsock, how woudl you transfer a connection to anohter port. i.e. have port 8888 be the connection port, then once it establishes a connection move that connection to another port. This would be a TCP port that i would be moving FROM (the connection) to a UDP or TCP connection. of course a UDP i coudl just have the client and server automatically use say 8886 all the time. Anywyas any ideas because i'm not sure how to do it. Thanks.
#2
sorry for the bump but i really need this answered.
02/06/2002 (5:31 pm)
How would i add 1 to the port number just for that one client, then 2 for the next one, woould i need to create more sockets? Also I need to keep track of which port i have set for each player, tho that probably won't be to hard as long as I figure out the first quesiton...sorry for the bump but i really need this answered.
#3
Accept returns a socket, use this socket to communicate with the client while your listener socket sits there and continues listening.
I usually set a maximum number of connections and create an array of sockets with a variable to hold the number of connections... something like this:
02/11/2002 (4:13 am)
You set a socket to listen at a specified port, once you have a connecting socket, you call accept.Accept returns a socket, use this socket to communicate with the client while your listener socket sits there and continues listening.
I usually set a maximum number of connections and create an array of sockets with a variable to hold the number of connections... something like this:
#define MAXCONNECTIONS 10 int numConnections = 0; SOCKET socClients[MAXCONNECTIONS];Then when you call accept() you can do this:
socClients[numConnections++] = accept(...);
if (socClients[numConnections - 1] == SOCKET_ERROR)
numConnections--;Hope that helps... if not, I'd suggest checking out www.sockets.com, good sample apps there. If you're still stuck, send an email and I'll try to help some more.
#4
02/11/2002 (10:25 am)
oh yeah... I learned that a long time ago (i havent' done network programming in over a year hehe). Thanks a lot man. If i have anymore questions i'll email ya =) thanks again!
Torque Owner David Chait
i'm sure there are tons of samples, anything doing TCP serving, of this on winsock. Even the MSDN website should have a bunch.
d