View Single Post
  #11   Spotlight this post!  
Unread 19-01-2012, 16:10
MohammadAdib MohammadAdib is offline
Outside-of-the-box thinker
FRC #0948 (NRG948)
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Bellevue WA
Posts: 7
MohammadAdib is an unknown quantity at this point
Re: Is TCP communication allowed in-game?

Quote:
Originally Posted by shuhao View Post
How are you getting the TCP comm link to work?

I'm currently unable to find the networking API from java..
In normal Java there are easy ways to implement a client server solution. From what i have seen/learned/experienced, it is always noteworthy that a client and server should talk with each other as little as possible while still maintaining communication. If your program requires sending a large amount of small data (such as coordinates) back and forth, then i suggest that you disable Nagle's algorithm, otherwise all of your small TCP packets will be made into one big packet and get sent, and that can mess things up quite a bit if you have some sort of command parser on the other side waiting to read the packets u send. Now that being said, in my opinion the ideal solution is to have the classmate running a server application listening on an open ServerSocket. A client will be on whatever you decide to send data to the classmate with which will try to connect to the classmate via some method of network communication. Then you can let the data flow. But if you are sending small amounts of data (< 1kb) then i recommend using a DatagramPacket (UDP). Regardless how you do it, Here is a useful site on making server and client solutions in Java: http://systembash.com/content/a-simp...nd-tcp-client/

If you have any technical questions about ANYTHING feel free to email me or something.

EDIT: I forgot to mention an extremely critical thing. Always make your servers threaded! That means for every client that connects to the ServerSocket on your server application, start a new designated thread for handling communication. If your server talks back, then also start another thread for sending info on the socket. Without threading, performance will TANK.

Last edited by MohammadAdib : 19-01-2012 at 16:14.