Connecting Python SocketServer with C# Client

后端 未结 3 1993
别跟我提以往
别跟我提以往 2021-01-14 06:29

I am trying to send data to Python via C# client. My code works when both the server and the client is either Python or C# but when I run the same code with C# client and Py

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-14 07:05

    I was able to resolve this issue by changing

    IPAddress ipAddress = ipHostInfo.AddressList[0];
    

    to

    IPAddress ipAddress = ipHostInfo.AddressList[2];
    

    It turns out AddressList[0] returns IPv6 Address and in Python socket.gethostname() returns IPv4 address.

提交回复
热议问题