我有这个代码发送客户端的IP地址,但它只显示一个客户端IP我的代码是
服务器端
from book import book
def printBook (b):
if b is None:
raise ValueError('invalid book arguement')
print (b.author + ": " + b.title + "\n" +" Number of page: " + b.numPages )
if __name__ == '__main__':
try:
b1 = book("The Eye of the World", "Robert Jordan", 685)
b2 = book("The Heir of Novron", "Michael J. Sullivan", 932)
printBook(b1)
printBook(b2)
except:
print("ERROR: INVALID BOOK")
客户端
var Client = new UdpClient();
var RequestData = Encoding.ASCII.GetBytes("Server Data");
var ServerEp = new IPEndPoint(IPAddress.Any, 0);
Client.EnableBroadcast = true;
Client.Send(RequestData, RequestData.Length, new IPEndPoint(IPAddress.Broadcast, 8888));
var ServerResponseData = Client.Receive(ref ServerEp);
var ServerResponse = Encoding.ASCII.GetString(ServerResponseData);
Console.WriteLine("Recived {0} from {1}", ServerResponse, ServerEp.Address.ToString());
Client.Close();