我正在尝试使用python套接字模块的聊天应用程序。我可以将台式电脑中的任何字符串发送到笔记本电脑,但不是其他方式。我正在使用UDP和IP,IPV4。
client.py:
namespace WebApi.Models
{
using System;
using System.Collections.Generic;
public partial class User
{
public int UserID { get; set; }
public string UserName { get; set; }
public string UserRole { get; set; }
}
}
server.py:
# Message Sender
import os
from socket import *
host = "192.168.1.14" #IP address of target computer
port = 13000
addr = (host, port)
UDPSock = socket(AF_INET, SOCK_DGRAM)
while True:
data = input("Enter a message to send or type 'exit': ")
UDPSock.sendto(data.encode("ascii"), addr)
if data == "exit":
break
UDPSock.close()
os._exit(0)
感谢您的帮助。