Archived

This topic is now archived and is closed to further replies.

Server changing ports?

This topic is 4943 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I finally worked out how to connect to a game server, and transfer login data, but after that, it appears the server changes ports and my connection is useless =/ Any suggestions on how to change my connected port without actually disconnecting and creating a new connection? (which I assume is bad). (c++, with winsock)

Share this post


Link to post
Share on other sites
i am guessing that you have a socket listening for a connection, and when a client tries to connect it creates a new socket to accept the connection. this is a pretty standard way of doing it, since the original listening socket can then continue listening for more connections. it doesn''t matter that the actual connection is a different port than what the client initially tries to connect to.

Share this post


Link to post
Share on other sites
um, sorry perhaps I was unclear.

I''ve written a client. After the login procedure, IRIS tells me that on the original client, it seems to hop ports on the server. I want to emulate this, but it doesn''t work if I initiate another connection on the new port. Perhaps there''s a way to change the target port after the connection is initiated? =/

Share this post


Link to post
Share on other sites
Yes. Using TCP, that is exactly how it works.

{I was confused when I wrote this section -- removed}

However, server is still listening on port X. If you want to create another connection, you still talk to port X.

I suggest getting a good primer on TCP/IP to figure out in more detail how the TCP protocol works.


EDIT: reading the additional information, it seems like you're trying to reverse engineer some protocol. If the protocol is that you first connect to X, and X tells you about Y, and you then connect to Y, then that's what you have to do. If the connection to Y is refused, then you're probably not adhering to whatever the protocol is (say, proper authentication for the protocol or similar). The specifics would be up to each protocol.

[edited by - hplus0603 on May 31, 2004 5:11:54 PM]

Share this post


Link to post
Share on other sites
sorry, maybe i misread...
quote:
connect to a game server, and transfer login data,

so the connection is made and stuff is communicated, and THEN the connection is lost? how do you know the server port changes?

Share this post


Link to post
Share on other sites
IRIS packet analyser.

I watch the original clients packets and they go like this

SEND (IP_PORT)
RECV (IP_PORT)
SEND (IP_PORT)
RECV (IP_PORT)
SEND (IP_PORT)
RECV (IP_PORT)
etc.
then after the login is complete, the PORT has changed. I've tried to emulate this by creating a new connection and connecting to the new port, but it gets rejected.

Besides, between the login finishing, and the character data being send on the new port, there isn't any extra packets. The original client isn't sending a new connection request.
--
hplus0603, I get the hang of it now just wondering how I change the port after the connect() has been made. target.sin_port = htons(PORT) ; does't do the business for me, because the recv() is left hanging without receving any data.

um, n/m. I get the hang of it now. Mabye some background reading would have been good before I jumped feet-first in to this ^_^ ty for the help

[edited by - mist350 on May 30, 2004 9:38:42 PM]

Share this post


Link to post
Share on other sites