fork download
  1. package yju.socket;
  2.  
  3. public class ClsMainServer {
  4.  
  5. public static void main(String[] args) {
  6. int port = 1234;
  7. TcpServer server = new TcpServer(port) {
  8.  
  9. @Override
  10. public void onConnect(SocketTransceiver client) {
  11. printInfo(client, "Connect");
  12. }
  13.  
  14. @Override
  15. public void onConnectFailed() {
  16. System.out.println("Client Connect Failed");
  17. }
  18.  
  19. @Override
  20. public void onReceive(SocketTransceiver client, String s) {
  21. printInfo(client, "Send Data: " + s);
  22. client.send(s);
  23. }
  24.  
  25. @Override
  26. public void onDisconnect(SocketTransceiver client) {
  27. printInfo(client, "Disconnect");
  28. }
  29.  
  30. @Override
  31. public void onServerStop() {
  32. System.out.println("--------Server Stopped--------");
  33. }
  34. };
  35. System.out.println("--------Server Started--------");
  36. server.start();
  37. }
  38.  
  39. static void printInfo(SocketTransceiver st, String msg) {
  40. System.out.println("Client " + st.getInetAddress().getHostAddress());
  41. System.out.println(" " + msg);
  42. }
  43. }
  44.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:3: error: class ClsMainServer is public, should be declared in a file named ClsMainServer.java
public class ClsMainServer {
       ^
Main.java:39: error: cannot find symbol
	static void printInfo(SocketTransceiver st, String msg) {
	                      ^
  symbol:   class SocketTransceiver
  location: class ClsMainServer
Main.java:7: error: cannot find symbol
		TcpServer server = new TcpServer(port) {
		^
  symbol:   class TcpServer
  location: class ClsMainServer
Main.java:7: error: cannot find symbol
		TcpServer server = new TcpServer(port) {
		                       ^
  symbol:   class TcpServer
  location: class ClsMainServer
4 errors
stdout
Standard output is empty