Closed emnylmz closed 5 years ago
Seems like there might be a misunderstanding here... Server.GetIPAdsresses() returns the IP’a that the server is listening on, not clients connected.
Server should fire off a client connected event, which will give you the tcpclient that you can use to send a message to that client.
Thanks for your answer. So how do I send messages from the server to the client? How can I access the ropes of clients connected to the server? Does SimpleTcpServer have a method for this?
Look at the “broadcast” message if you want to send something to all connnected clients.
Or add a handler to the ClientConnected event to be notified when a client is connected and get the individual client’s object.
Problem is solved. Thanks. :)
I want to send messages to clients connected to the server. But the GetIpAdresses method gives me my own ip address or my local address (127.0.0.1).
SimpleTcpClient client; private void button1_Click(object sender, EventArgs e) { foreach (var serverIp in server.GetIPAddresses()) { client = new SimpleTcpClient(); client.StringEncoder = Encoding.UTF8; client.DataReceived += Client_DataReceived; client.Connect(serverIp.ToString(),23); client.WriteLineAndGetReply(rtb_server_message.Text, TimeSpan.FromSeconds(10)); }