Server.java 614 B

1234567891011121314151617181920212223
  1. package com.oblivm.backend.network;
  2. import java.io.BufferedInputStream;
  3. import java.io.BufferedOutputStream;
  4. import java.io.IOException;
  5. import java.net.ServerSocket;
  6. public class Server extends Network {
  7. public void listen(int port) {
  8. try {
  9. serverSock = new ServerSocket(port);
  10. sock = serverSock.accept(); // wait for client to connect
  11. os = new BufferedOutputStream(sock.getOutputStream());
  12. is = new BufferedInputStream(sock.getInputStream());
  13. } catch (IOException e) {
  14. // TODO Auto-generated catch block
  15. e.printStackTrace();
  16. } // create socket and bind to port
  17. setUpThread();
  18. }
  19. }