¡¾JavaÍøÂç±à³ÌÒ»¡¿Ò»¸ö¼òµ¥µÄc/s³ÌÐò
ʵÑéÒªÇó£º
1.±àд»ùÓÚTCPÐÒéµÄͨÐųÌÐò£¬°üÀ¨ServerÓëClientÁ½¸ö²¿·Ö¡£ÊµÏÖ»ØÉù³ÌÐò£º¼´¿Í»§¶Ë·¢ËÍÏûÏ¢£¬·þÎñÆ÷¶Ë½«ÊÕµ½µÄÏûÏ¢ÔÑù»áË͸ø¿Í»§¶Ë¡£
2.ÔÚµ¥»úÉÏÔËÐÐËüÃÇ£¬ÑéÖ¤ÆäͨÐŽá¹û£»
3.ÔÚ¶à»úÉÏÔËÐÐËüÃÇ£¬ÑéÖ¤ÆäͨÐŽá¹û£»£¨ChatServerÖ»ÐèÔËÐÐÔÚһ̨Ö÷»úÉÏ£¬ChatClient¿ÉÔÚÆäËüÖ÷»úÉÏÔËÐУ¨ÒªÖªµÀChatServerËùÔÚÖ÷»úµÄIPµØÖ·£©¡£
4£®Ìáʾ£º·þÎñÆ÷¶Ë»ØËÍÏûϢʱ£¬¿ÉÒÔ½øÐмӹ¤£¬ÀýÈç¸øÿ¸öÊÕµ½µÄÏûÏ¢¼ÓÉÏ“·þÎñÆ÷»ØËÍ”+ÔʼÏûÏ¢+·þÎñÆ÷¶ËÊÕµ½ÏûÏ¢µÄʱ¼ä£»
5£®¿Í»§¶Ë¿ÉÒÔ´Ó4×Ö½ÚÊý¾Ý¿ªÊ¼·¢ËÍ£¬Öð½¥Ôö´óÊý¾ÝÁ¿£¬¹Û²ì´ÓÉÙÁ¿Êý¾ÝµÄ·¢Ë͵½´óÁ¿Êý¾ÝµÄ·¢ËÍ£¬Ê±¼äÐÔÄܵı仯£¬¼Ç¼ÿ´Î·¢ËÍÊý¾ÝËùÐèʱ¼ä£¬ÀûÓÃexcelÖÆ×÷ÇúÏßͼ£¨¸Ã²¿·ÖʵÑé¿ÉÑ¡£©
Ô´Â룺
·þÎñÆ÷¶Ë£º
package tcpipchapter3;
import java.io.*;
import java.net.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class server {
/**
* @param args
*/
//ÉèÖö˿ںÅ\
public static int portNo=3333;
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
//³õʼ»¯serverSocketÀà
ServerSocket s=new ServerSocket(portNo);
System.out.println("The Server is starting...");
//½¨Á¢socketÁ¬½Ó(×èÈû£¬Ö±µ½Óпͻ§¶ËÁ¬½Ó)
Socket socket=s.accept();
//½ÓÊÕÊý¾Ý
try{
//¹¹ÔìÊäÈëÁ÷»º´æ
BufferedReader bufReader=new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter out=new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
String time=new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").format(new Date());
while(true){
//°´ÐжÁÈ¡ÊäÈëÄÚÈÝ
String strLine=bufReader.readLine();
//Èç¹ûÊÕµ½byebyeÔòÍ˳öÑ»·
if(strLine.equals("byebye")){
break;
}
&n
Ïà¹ØÎĵµ£º
“Éϵ۸³ÓèÈËÀà˵»°µÄÄÜÁ¦£¬¶øÑÔÓïÓÖ´´ÔìÁË˼Ï룬˼ÏëÊÇÈËÀà¶ÔÓîÖæµÄÁ¿¶È¡£”
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡——Õª×Ô¡¶Prometheus Unbound¡·£¬Shelley
? ÈËÀà……¼«ÆäÊÜÄÇЩÒѾ³ÉΪÉç»á±í´ï¹¤¾ßµÄÌض¨ÓïÑÔµÄÖ§Åä¡£ÏëÏñһϣ¬Èç¹ûÒ»¸öÈË¿ÉÒÔ²»Ê¹ÓÃÓïÑÔ¾ÍÄܹ»´Ó±¾ÖÊÉÏÊÊÓ¦ÏÖÊµÊ ......
Ò»¡¢³éÏóÀà×¢ÒâÊÂÏ
1£¬³éÏóÀàÖпÉÒÔÓÃ0+¸ö³éÏó·½·¨¡£
2£¬ÓгéÏó·½·¨µÄµÄÀà±ØÐëÊdzéÏóÀà¡£
3£¬³éÏóÀàÅÉÉúµÄ·Ç³éÏó×ÓÀà±ØÐëʵÏÖ³éÏóÀàÖж¨ÒåµÄËùÓгéÏó·½·¨¡£
4£¬³éÏóÀ಻ÄÜ´´½¨¶ÔÏó¡£
5£¬abstract ²»ÄÜÓëfinal²¢ÁÐÐÞÊÎͬһ¸öÀà
6£¬abstract²»ÄÜÓëprivate,static ,final,native²¢ÁÐÐÞÊÎͬһ·½·¨¡£
package com.wens ......
1.JavaµÄ´úÂëÒ»°ã·ÖΪÁ½´óÀࣺһÖÖÊǽṹ¶¨ÒåÓï¾ä£»Ò»ÖÖÊǹ¦ÄÜÓï¾ä£¨¹¦ÄÜÓï¾äÒªÓ÷ֺŽá⣩¡£
2.ÓÃ/* ÄÚÈÝ */×¢ÊÍ£¬ÄÚÈÝÀïÃæÊDz»ÄÜ´æÔÚ/* */µÄ£»µ«ÊÇ¿ÉÒÔ´æÔÚ//£»ÒòΪÕâÑù¾Í²»»á·¢Éúϵͳ²»ÖªµÀÄĸö*/²ÅÊÇÕæµÄ½áÊø·û¡£
3.±äÁ¿Ê¹ÓÃÇ°±ØÐë³õʼ»¯£¬Ê¹Óõ¥ÒýºÅµÄ×÷ÓþÍÊÇ°ÑÀïÃæµÄ×Ö ......
#include <iostream>
#include <cstdlib>
using namespace std;
class Foo
{
public:
Foo(int ii):i(ii){}
int getInt(){return i;}
private:
int i;
};
class Bar
{
public:
static int FooVal(){c++; return f.getInt();}
int callsFooVal(){return c;}
private:
s ......