Skip to content

Commit

Permalink
🐛 FIX. 소켓 연결 오류 수정
Browse files Browse the repository at this point in the history
클라이언트 서버 접속 오류 수정

related to : #2, #3
  • Loading branch information
junhaa committed Dec 17, 2023
1 parent e2d94ff commit 79f52a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/Controller/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public synchronized void setFlag() {

public void connect(String address, int port, String name) throws UnknownHostException, NotEmptySpaceException, OnProgressException{
try {
System.out.println("연결을 시도합니다.");
curSocket = new Socket(address, port);
System.out.println(curSocket);
this.out = new ObjectOutputStream(curSocket.getOutputStream());
this.in = new ObjectInputStream(curSocket.getInputStream());

Expand Down
7 changes: 6 additions & 1 deletion src/Controller/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ public void run() {
ServerSocket serverSocket;
try {
serverSocket = new ServerSocket(port);
System.out.println("server 소켓 생성");
System.out.println("server 소켓 생성, IP : " + serverSocket.getLocalSocketAddress());
System.out.println(InetAddress.getLocalHost().getHostAddress());

InetAddress serverLocalIpAddress = serverSocket.getInetAddress();
System.out.println("Serversocket Local IP Address : " + serverLocalIpAddress.getHostAddress());
while(true) {
System.out.println("기다리는 중");
Socket clientSocket = serverSocket.accept();
System.out.println("클라이언트 연결됨: " + clientSocket.getInetAddress().getHostAddress());

Expand Down
4 changes: 1 addition & 3 deletions src/View/GameView.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ public void actionPerformed(ActionEvent e) {
String name = nameTF.getText();
String address = addressTF.getText();

System.out.println(isValidIP(address));

if(name.isEmpty() || name.isBlank()){
loginErrorLabel.setText("이름을 입력해주세요.");
return;
Expand All @@ -225,8 +223,8 @@ else if(address.isEmpty() || address.isBlank() || !isValidIP(address)){
loginErrorLabel.setText("올바른 IP주소를 입력해주세요.");
return;
}
System.out.println(nameTF.getText().isEmpty());
System.out.println("IP주소 : " + addressTF.getText() + "로 연결을 시도합니다.");
gameController.connectRoom(addressTF.getText());
}
});

Expand Down

0 comments on commit 79f52a1

Please sign in to comment.