Author |
Message |
Cerium Server Help Squatter

Age:43 Gender: Joined: Mar 05 2005 Posts: 807 Location: I will stab you. Offline
|
Posted: Tue Jul 26, 2005 3:04 am Post subject: Noop |
 |
|
|
|
Is there any way for a client to request that the keep alive (NOOP) message be sent/not sent periodicly by the server? _________________ There are 7 user(s) ignoring me right now. |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Tue Jul 26, 2005 3:12 am Post subject: |
 |
|
|
|
Looking at the 140 code it seems the server sends a NOOP to a client if it hasn't sent anything s2c for 3 minutes. So you could send a command to the server every 2 minutes and maybe hide the response from the user, but I don't think this is what you are looking for. |
|
Back to top |
|
 |
Cerium Server Help Squatter

Age:43 Gender: Joined: Mar 05 2005 Posts: 807 Location: I will stab you. Offline
|
Posted: Tue Jul 26, 2005 3:34 am Post subject: |
 |
|
|
|
I see.
Yeah, im kinda looking for some kinda message so the user can control if/when thats sent (kinda like the keep alive packet in the SS protocol).
Basicly, the Socket object in java isnt very friendly for designing timeout checks, unless im willing to let it my inputstream block for an ungodly long time, then throw an exception (which im not). |
|
Back to top |
|
 |
Grelminar Creator of Asss
Joined: Feb 26 2003 Posts: 378 Offline
|
Posted: Tue Jul 26, 2005 4:30 am Post subject: |
 |
|
|
|
You don't have to send a command, just send a NOOP yourself. It will be correctly ignored.
What's wrong with doing nothing special, and letting the server send NOOPs? You also might want to have an option in your client to send them periodically, to deal with crappy NAT devices that incorrectly drop open TCP connections.
I haven't used sockets in java, but there must be a way to set up your control flow so that you both receive data from the network when it comes in, and also can be woken up for timers. Perhaps you need to look at the asynchronous i/o libraries. |
|
Back to top |
|
 |
Cerium Server Help Squatter

Age:43 Gender: Joined: Mar 05 2005 Posts: 807 Location: I will stab you. Offline
|
Posted: Tue Jul 26, 2005 6:44 am Post subject: |
 |
|
|
|
async operations arent the problem here, I just was wondering if there was a way to tell the server to send them, since the docs seemed to hint that NOOP may not be sent often, if at all.
Sockets in java are easy to work with, its just the timeout checks which arent friendly. Im no pro, but the only way I know of is to set the timeout in the socket (via setSoTimeout), then tell your inputstream to .read, which will block until it gets data, or until the timeout has been reached, which results in an exception.
Ill probably restructure my receiver to use that method instead of my hack method now, and hope no outside sources decide to close the connection =) |
|
Back to top |
|
 |
Dr Brain Flip-flopping like a wind surfer

Age:39 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: Tue Jul 26, 2005 9:04 am Post subject: |
 |
|
|
|
Can't you just check the type of the exception? _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
 |
Cerium Server Help Squatter

Age:43 Gender: Joined: Mar 05 2005 Posts: 807 Location: I will stab you. Offline
|
Posted: Tue Jul 26, 2005 11:52 am Post subject: |
 |
|
|
|
Yup. SocketTimeoutException. |
|
Back to top |
|
 |
Smong Server Help Squatter

Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Wed Jul 27, 2005 3:16 am Post subject: |
 |
|
|
|
Grelminar wrote: | You don't have to send a command, just send a NOOP yourself. It will be correctly ignored. |
/* send noop if we haven't sent anything to this client for
* 3 minutes */
if (TICK_DIFF(gtc, cli->lastsendtime) > 18000)
sp_send(cli, "NOOP"); |
The only place cli->lastsendtime gets modified is when the player connects and gets created or in do_sp_write() which gets called when something is sent s2c.
int do_sp_write(sp_conn *conn)
{
Link *l = LLGetHead(&conn->outbufs);
if (l && l->data)
{
...
conn->lastsendtime = current_ticks();
}
return 0;
} |
|
|
Back to top |
|
 |
Grelminar Creator of Asss
Joined: Feb 26 2003 Posts: 378 Offline
|
Posted: Wed Jul 27, 2005 3:43 am Post subject: |
 |
|
|
|
Yes, that looks correct. The server will send a NOOP every three minutes, if no other traffic has been sent. It's not configurable, although it wouldn't be hard to make it configurable, if there's a good reason for it.
Now that I think about it, it should reset the timer (not "lastsendtime", but use another timer) for any c2s traffic as well, since this being tcp, c2s traffic implies packets flowing s2c also. The point is just to hack around broken NAT devices, so any packets at all are sufficient. |
|
Back to top |
|
 |
|