Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi all,

 

Have written a simple TCPServer, see code below, that is suppose to listen at a certain port for a message and print that message. If I use for example port 8001, then the code works perfectly. However I need to listen to port 80, for an email with a specific header. When the email with the correct header is received at port 80, I need my code to respond in a specific manner. The problem is that when I try and connect to port 80, I get the following exception:

 

Error.....    at System.Net.Sockets.Socket.Bind(EndPoint localEP)
  at System.Net.Sockets.TcpListener.Start()
  at TCPServer.Form1.btnServer_Click(Object sender, EventArgs e) in c:\documents and settings\modonnell.itec\my documents\visual studio projects\tutorials\c-sharp\tcpserver\form1.cs:line 98

 

Any suggestions on why this problem is occuring, I think it might be to do with security related issues.

 

Mike55.

 

try
{
 IPAddress ipAD = IPAddress.Parse("xxx.xxx.x.x");
 TcpListener myList = new TcpListener(ipAD, 80);
			
 myList.Start();
 Console.WriteLine("The server is running at port 8001");
 Console.WriteLine("The local End point is : "+myList.LocalEndpoint);
 Console.WriteLine("Waiting for a connection.");
			
 Socket s = myList.AcceptSocket();
 Console.WriteLine("Connection Accepted from : "+ s.RemoteEndPoint);
			
 byte [] b=new byte[100];
 int k=s.Receive(b);
 Console.WriteLine("Received...");
 for (int i =0; i<k; i++)
   Console.WriteLine(Convert.ToChar(b[i]));
			
 ASCIIEncoding asen=new ASCIIEncoding();
 s.Send(asen.GetBytes("The string was recieved by the server."));
 Console.WriteLine("\nSent Acknowledgement");
			 
 s.Close();
 myList.Stop();
}
		
catch (Exception a) 
{
  Console.WriteLine("Error..... " + a.StackTrace);
} 

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted
Is IIS running on the PC? If so then it will be using port 80. Why are you expecting an e-mail on port 80 anyway?

 

My fault, got the port numbers mixed up, need to listen to port 25 and 110. Can connect to and listen to 110, but not 25. Any suggestions??

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted
Again does the PC have the SMTP service running? If so it will grab port 25.

 

Ok, see what you mean. Is it anyway possible for my program to share port 25 with ISS SMTP??

 

Mike55

A Client refers to the person who incurs the development cost.

A Customer refers to the person that pays to use the product.

------

My software never has bugs. It just develops random features. (Mosabama vbforums.com)

Posted
Ok, see what you mean. Is it anyway possible for my program to share port 25 with ISS SMTP??

 

Mike55

A port is virtual. It is simply a "process identifier" -- meaning it can only identify a single process at a time.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...