Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11855 Posts in 1569 Topics- by 3045 Members - Latest Member: lensreslai

10. February 2012, 05:51:02 AM
Xith3D CommunityGeneral CategoryFeature Requests & Brilliant Ideas (Moderators: Marvin Fröhlich, 'n ddrylliog)Net-code
Pages: 1 2 [3] 4 5
Print
Author Topic: Net-code  (Read 15150 times)
Pandaemonium
Enjoying the stay
*
Offline Offline

Posts: 85


If at first you don't succeed; call it version 1.0


View Profile
« Reply #30 on: 19. December 2007, 05:33:05 AM »

Attached you will find 3 files, that makes a simplistic test case for client server communication using Mina. The implementation demonstrates the following features:

* Where a custom codec protocol can be "plugged in"
* Multiple clients can connect to the server
* A single Handler handles requests from all the clients
* How to build a filter chain
* The asynchronous behavior of the client and server
* The ease of passing data between client and server

When a client starts up, it simply generates values to the server. Once the sever receives two values from a client, it adds them together and returns the result. I know this is simplistic, but it definitely shows how easy it is to store "state" per client.

If someone can run this through a profiler, it would be appreciated. @Amos, I could send an email to the guys at YourKit, but figured it'd be faster to just go ahead and post the files.
Logged
Pandaemonium
Enjoying the stay
*
Offline Offline

Posts: 85


If at first you don't succeed; call it version 1.0


View Profile
« Reply #31 on: 19. December 2007, 05:34:55 AM »

Since I had a limit of 4 attachments only, here are the jars that will be needed.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #32 on: 19. December 2007, 06:41:56 PM »

Nice. I will have a look at this this evening...

Since I had a limit of 4 attachments only, here are the jars that will be needed.

Hmmm... I just don't get, why people don't simply zip the files into one archive Wink.

Marvin
Logged
Pandaemonium
Enjoying the stay
*
Offline Offline

Posts: 85


If at first you don't succeed; call it version 1.0


View Profile
« Reply #33 on: 19. December 2007, 08:18:30 PM »

Quote
Hmmm... I just don't get, why people don't simply zip the files into one archive

Hehe. I thought of that after the fact, but I guess because my wife was nagging me and I couldn't think straight.  Lips sealed
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #34 on: 19. December 2007, 08:45:11 PM »

Hehe. I thought of that after the fact, but I guess because my wife was nagging me and I couldn't think straight.  Lips sealed

Grin

When I try to run the server or client I get the following exception:
Code:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
at org.apache.mina.filter.executor.ExecutorFilter.<init>(ExecutorFilter.java:48)
at org.apache.mina.filter.executor.ExecutorFilter.<init>(ExecutorFilter.java:57)
at org.apache.mina.common.ExecutorThreadModel.<init>(ExecutorThreadModel.java:76)
at org.apache.mina.common.ExecutorThreadModel.getInstance(ExecutorThreadModel.java:64)
at org.apache.mina.common.support.BaseIoServiceConfig.<init>(BaseIoServiceConfig.java:45)
at org.apache.mina.common.support.BaseIoConnectorConfig.<init>(BaseIoConnectorConfig.java:35)
at org.apache.mina.transport.socket.nio.SocketConnectorConfig.<init>(SocketConnectorConfig.java:40)
at org.apache.mina.transport.socket.nio.SocketConnector.<init>(SocketConnector.java:62)
at org.apache.mina.transport.socket.nio.SocketConnector.<init>(SocketConnector.java:84)
at mina.TestMinaClient.<init>(TestMinaClient.java:37)
at mina.TestMinaClient.main(TestMinaClient.java:108)

What additional jar do I have to download and include? Or can I do anything to work without logging. I don't want mina to log on its own in the end.

Marvin
Logged
Pandaemonium
Enjoying the stay
*
Offline Offline

Posts: 85


If at first you don't succeed; call it version 1.0


View Profile
« Reply #35 on: 20. December 2007, 12:00:15 AM »

Quote
What additional jar do I have to download and include? Or can I do anything to work without logging. I don't want mina to log on its own in the end.

Damn it, I forgot to include the slf4j-jdk.jar. Slf4j is needed if your logging is java.util.logging (which I think Xith3d uses). I'm not at home right now, but you can grab all the slf jars at: http://www.slf4j.org/download.html Put slf4j-api.jar and slf4j-jdk14.jar into your project classpath.

I've always used the logging capabilities of Mina (handy for seeing the actual bytes that are sent to and from the server and client) but you should be able to turn it off by simply removing the logger from the filter chain. So in this case, you don't need to worry about the slf jars.

Let me know if you have any other problems.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #36 on: 20. December 2007, 12:35:38 AM »

Damn it, I forgot to include the slf4j-jdk.jar.
...
I'm not at home right now, but you can grab all the slf jars at: http://www.slf4j.org/download.html Put slf4j-api.jar and slf4j-jdk14.jar into your project classpath.

Yeah, works. Thanks.

Slf4j is needed if your logging is java.util.logging (which I think Xith3d uses).

Nope. We're not using log4j or java.util.logging. We're using JAGaToo's logging facility.

I've always used the logging capabilities of Mina (handy for seeing the actual bytes that are sent to and from the server and client) but you should be able to turn it off by simply removing the logger from the filter chain. So in this case, you don't need to worry about the slf jars.

Well, the execption was thrown before the logging filter was put into the chain. But I will see...

Let me know if you have any other problems.

Sure. Thanks so far.

Marvin
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #37 on: 20. December 2007, 12:42:12 AM »

Oh, btw. How is server broadcasting done through mina? E.e. how to I find servers an a known sub-set?

Marvin
Logged
Pandaemonium
Enjoying the stay
*
Offline Offline

Posts: 85


If at first you don't succeed; call it version 1.0


View Profile
« Reply #38 on: 20. December 2007, 07:05:03 AM »

Oh, btw. How is server broadcasting done through mina? E.e. how to I find servers an a known sub-set?

Marvin

I'm not sure I understand what you mean. Are you asking how to determine all the active hosts given a set of IPs? If so, you can use a utility like Nmap. (http://insecure.org/nmap/man/man-host-discovery.html)

But from the context of Mina, you should know beforehand the name of the host and the port. So from Mina's standpoint, it's just a matter of defining a server to listen on a port (say, port 5555) and then having the client connect.

Did I answer your question?
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #39 on: 20. December 2007, 12:25:02 PM »

I'm not sure I understand what you mean. Are you asking how to determine all the active hosts given a set of IPs? If so, you can use a utility like Nmap. (http://insecure.org/nmap/man/man-host-discovery.html)

But from the context of Mina, you should know beforehand the name of the host and the port. So from Mina's standpoint, it's just a matter of defining a server to listen on a port (say, port 5555) and then having the client connect.

Did I answer your question?

Well, I would need a Java solution. And NMap doesn't seem to be one.

Marvin
Logged
kukanani
Fierce Warrior
****
Offline Offline

Posts: 504


My game is coming along fairly smoothly...


View Profile WWW
« Reply #40 on: 20. December 2007, 03:09:15 PM »

Well, is it even possible to do that with normal client/server Java?  Server broadcasting, I mean.

EDIT:  I just remembered something.  Couldn't you just use a UDP broadcast to keep track of which hosts were on and which weren't?  When a server comes "online", it starts slowly broadcasting to UDP (on a specified port).  Then just scan the UDP address and get all of the hosts online.
« Last Edit: 20. December 2007, 03:11:55 PM by kukanani » Logged

xith.setCoolnessLevel(10);
jMe.setCoolnessLevel(0);
xith.rock();
Pandaemonium
Enjoying the stay
*
Offline Offline

Posts: 85


If at first you don't succeed; call it version 1.0


View Profile
« Reply #41 on: 20. December 2007, 04:39:51 PM »

Well, is it even possible to do that with normal client/server Java?  Server broadcasting, I mean.

EDIT:  I just remembered something.  Couldn't you just use a UDP broadcast to keep track of which hosts were on and which weren't?  When a server comes "online", it starts slowly broadcasting to UDP (on a specified port).  Then just scan the UDP address and get all of the hosts online.

Yes, this is called a UDP Probe or a UDP Ping. There are many different ways to find a set of hosts. You can also ping the broadcast address. ( ping -b <broadcast ip> )

I'm still confused though on what the overall problem/goal is. Why do you need this?

I have been thinking about using JGroups (a reliable multicast API) for my chat-server implementation, but I'm not sure if this would suit your needs.
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #42 on: 20. December 2007, 06:40:18 PM »

I'm still confused though on what the overall problem/goal is. Why do you need this?

Well, simple: Consider, you have a multiplayer (online) game and want to find servers to connect to and to play on. You would not want to ask someone for the IP of a valid host. In most cases for online gaming you would not even get to know.

Any today's multiplayer game has that: Find servers, select one, connect. I guess, you know that, do you?

Marvin
Logged
Pandaemonium
Enjoying the stay
*
Offline Offline

Posts: 85


If at first you don't succeed; call it version 1.0


View Profile
« Reply #43 on: 20. December 2007, 10:31:59 PM »

Well, simple: Consider, you have a multiplayer (online) game and want to find servers to connect to and to play on. You would not want to ask someone for the IP of a valid host. In most cases for online gaming you would not even get to know.

Any today's multiplayer game has that: Find servers, select one, connect. I guess, you know that, do you?

Marvin

Yep, I do know that. But this problem (and it gives way to several other issues) is outside the scope of what Mina handles. Mina is simply a low-level socket communication framework.

Since we definitely want to consider large scale, here's what I would assume is needed (in my limited experience):

Suppose you have a datacenter in West Coast US, East Cost US, and Central Europe. So the goal then is to give a list of servers to the user so he can pick one that he wants. Perhaps we want to visually indicate to the user which servers have the lowest latency, or which ones have the lowest population, or whatever, to help the user make a decision. 

The client still needs to connect to a central server, let's call it Login Server. So as far as coding the client goes, it would simply connect to the Login Server, request a list of servers, and get a response. The host name and port must still be needed beforehand. This is the step in which I was referring to, and why I was getting confused  Wink The task of monitoring a cluster's health, or which servers are down/available should all be done on the server side.

So then, we can assume that the Login Server would probably utilize a utility to make it easy to return a list of servers and the statistics we're interested in displaying back to the user. Something on the server side still needs to know about all of the servers. It's possible to make the servers a part of the same multi-cast group. Thus, when a server is brought up, it would join the group and broadcast a message (probably to a server controller of some sort). Of course, all of this is very dependent upon load balancers, if there are clusters, if there are servers delegated to certain zones, etc. When a user chooses a server, the Login Server or some other designated server on the hosting side would return the correct data center's IP. The client would then use the returned IP address for it's socket. This is just one option. The point is, this technology needs constructed outside the scope of Mina.

I know Darkstar addresses some of these issues, but I axed using that option for myself for a couple reasons. Arianne looks ok but I prefer the ability to create my own protocol and transport. I don't want to be forced to use UDP and their packet format (which should be sufficient for most).

Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #44 on: 20. December 2007, 11:38:59 PM »

I totally agree. I was just wondering, how other games do that. In a LAN we can certainly search all 254 possible hosts (by trying to connect) and find the server this way. Could be abstracted of course. But for an online game there must be some kind of master server, which holds a list of servers.

So, I guess, during the cristmas days I can address the Mina abstraction. I just hope, that shadows are working till then.

Marvin
Logged
Pages: 1 2 [3] 4 5
Print
Jump to:  

Theme orange-lt created by panic