游戏公司往往在运行初期要投入大批资金,购买高性能服务器。可是,一旦进入赢利期,后续的投入几乎可以不计,所以,行业内的投入主要在于游戏规则的创设,代码的编写,以及带宽的租用,服务器的购买或者租用。
中小型游戏:玩家规模比较大,通常普通云服务器承载会有着一定的压力,此时建议选择独立游戏服务器或高频云服务器。值得一提的是,随着游戏运营,游戏玩家规模的增长会需求服务器配置的升级,因此需要选择能够升级服务器配置。
大型游戏:对服务器要求很高,在选择游戏服务器租用时需要对服务器、数据中心、IDC商进行综合的考量。import javaioBufferedReader;
import javaioIOException;
import javaioInputStreamReader;
import javaioPrintWriter;
import javanetServerSocket;
import javanetSocket;
publicclass Server
{
private ServerSocket ss;
private Socket socket;
private BufferedReader in;
private PrintWriter out;
public Server()
{
try
{
ss = new ServerSocket(10000);
while (true)
{
socket = ssaccept();
String RemoteIP = socketgetInetAddress()getHostAddress();
String RemotePort = ":" + socketgetLocalPort();
Systemoutprintln("A clientcome in!IP:" + RemoteIP
+ RemotePort);
in = new BufferedReader(new
InputStreamReader(socketgetInputStream()));
String line = inreadLine();
Systemoutprintln("Cleint sendis :" + line);
out = new PrintWriter(socketgetOutputStream(), true);
outprintln("YourMessage Received!");
outclose();
inclose();
socketclose();
}
}
catch (IOException e)
{
outprintln("wrong");
}
}
publicstaticvoid main(String[] args)
{
new Server();
}
}
import javaioBufferedReader;
import javaioIOException;
import javaioInputStreamReader;
import javaioPrintWriter;
import javanetSocket;
publicclass Client {
Socket socket;
BufferedReader in;
PrintWriter out;
public Client()
{
try
{
Systemoutprintln("Try toConnect to 127001:10000");
socket = new Socket("127001", 10000);
Systemoutprintln("The ServerConnected!");
Systemoutprintln("Pleaseenter some Character:");
BufferedReader line = new BufferedReader(new
InputStreamReader(Systemin));
out = new PrintWriter(socketgetOutputStream(), true);
outprintln(linereadLine());
in = new BufferedReader(new InputStreamReader(socket
getInputStream()));
Systemoutprintln(inreadLine());
outclose();
inclose();
socketclose();
}
catch (IOException e)
{
outprintln("Wrong");
}
}
publicstaticvoid main(String[] args)
{
new Client();
}
}
你再改改代码就可以了但我没时间帮你调了……
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)