0

I brought the question up a few days back on how to output/parse an IP address. Some suggestions were provided, and after a couple days of hitting my head against the wall, attempting the different suggestions, I'm no further. I'm sure the suggestions were OK, but the method in which I was trying to utilize them is where I failed.

So...I'd like to start from just a basic perspective.

  {
        BaseClient bc = null;
        try
        {
            if (m_TCP_Socket == null)
            {
                Console.Write("Client disconnected");
            }
            else
            {   

                //Console.WriteLine("New TCP connection made.");

                bc = GetNewClient();
                bc.Socket = m_TCP_Socket.EndAccept(ar);
                lock (m_clients)
                    m_clients.Add(bc);

                bc.OnConnect();
                bc.BeginReceive();
            }
}

}

I would like for it to simply console out, "New TCP Connection made. IP:###.###.###.###. If you respond, please don't be to presumptuous about what I may know, and not know, as I am student, and trying to learn things.

user1901231
  • 47
  • 1
  • 8

1 Answers1

1

It's all in the manual. Socket.EndAccept() returns a Socket, from which you can read the RemoteEndPoint property which will be an IPEndPoint, which has an Address property. I think you're looking for the latter.

CodeCaster
  • 147,647
  • 23
  • 218
  • 272