80,351
社区成员
发帖
与我相关
我的任务
分享
static int clientNum = 1;
public static void main(String[] args) {
// TODO code application logic here
ServerSocket server = null;
try{
server = new ServerSocket(8316);
}catch(IOException e){
e.printStackTrace();
System.exit(-1);
}
while(true){
try{
Socket ss = server.accept();
new ServerThread(ss,clientNum).start();
}catch(Exception e){
e.printStackTrace();
}
clientNum++;
}
}
}
public class MobileNewsActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Socket socket = null;
DataInputStream dis;
try{
socket = new Socket("192.168.0.110 ",8316);
dis = new DataInputStream(socket.getInputStream());
}catch(Exception e){
e.printStackTrace();
}
setContentView(R.layout.main);
}
}