2016-10-17 4 views
0

나는 네트워킹에 대해 배우고 있었고 무엇이 잘못되었는지 이해하는 데 어려움이있었습니다.컴퓨터간에 소켓 연결 설정?

나는 클라이언트와 서버 스크립트를 생성 :

서버 :

import socket 

s = socket.socket() 
host = socket.gethostname() 
port = 12345 
s.bind((host,port)) 

s.listen(5) 
while True: 
    c, addr = s.accept() 
    print ("Got connection from: " ,addr) 
    c.send("Thanks".encode('utf-8')) 
    # c.sendto(("Thank you for connection").encode('utf-8'), addr) 
    c.close() 

및 클라이언트 :

import socket 

s=socket.socket() 
host=socket.gethostname() 
port = 12345 

s.connect((host,port)) 
c=s.recv(1024) 
print (c) 

s.close 

나는 (아무 문제가 내 컴퓨터에서 실행하려합니다 두 스크립트 모두) 그러나 다른 컴퓨터에서 클라이언트를 실행하면 다음 오류가 클라이언트에 대해 팝업됩니다. ConnectionRefuseError: WinError10061 No connection could be made because the target machine actively refused it.

이 문제를 해결할 수있는 아이디어가 있습니까?

답변

0

문제는 다른 컴퓨터에서 실행할 때 나는 서버 IP를 참조되지 않았 음을했다,이 호스트 = "10.xxx"

같은 클라이언트 스크립트에서 서버 IP를 통과하여 고정 쓸모없는 질문을 만들어서 죄송합니다!