Mountaineer Eth Mainboards DO have socket communication abilities correct?
I’m stepping through my code and when i try to listen for socket messages i continue to get exceptions when when i try to bind the LocalEndPoint. Since it gets exceptions I never get to listen to the port. Here is part of my code.
public void StartListening()
{
IPHostEntry ipHostInfo = null;
IPEndPoint localEP = new IPEndPoint(IPAddress.Parse("192.168.1.50"), port);
if (ipAddress == string.Empty)
localEP = new IPEndPoint(ipHostInfo.AddressList[2], port);
else
localEP = new IPEndPoint(IPAddress.Any, port);
Socket listener = new Socket(AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp);
while (!bShutdown)
{
try
{
listener.Bind(localEP);
listener.Listen(10);
listener.Accept();
Its always a SocketException even though i thought that i was creating the socket the correct way but apparently i can’t access it. How can i fix this?
you are not telling us where you are getting the exception.
you should only bind and listen once. not sure why you have it in a while loop.
you should also be interested in the return fron the accept statement since it is the socket you should use to communicate with the remote host who has just connected.
also use the ipaddress any for the bind.
included with the MS SDK are some good socket examples.