Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Port 25!!!!?????

Port 25!!!!?????

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    students552 university
    wrote on last edited by
    #1

    Hi all I want to know as to how to write a program in C# to recieve characters from the internet port(like port 25)and store it in a file. Can someone help me with the code or any help for such a programe?????????????!!!!!!!!!!! Thanks. :)

    M 1 Reply Last reply
    0
    • S students552 university

      Hi all I want to know as to how to write a program in C# to recieve characters from the internet port(like port 25)and store it in a file. Can someone help me with the code or any help for such a programe?????????????!!!!!!!!!!! Thanks. :)

      M Offline
      M Offline
      mav northwind
      wrote on last edited by
      #2

      Hi! A small example, written from memory, for you to start with:

      System.Net.Sockets.TcpListener listener = new System.Net.Sockets.TcpListener(25);
      listener.Start();
      do
      {
      if (listener.Pending())
      {
      System.Net.Sockets.TcpClient client = listener.AcceptTcpClient();

      	byte\[\] buf = new byte\[client.ReceiveBufferSize\];
      	int len = client.GetStream().Read(buf, 0, buf.Length);
      	// TODO: Handle longer data and writing to file
      	MessageBox.Show(len+" bytes received");
      } 
      else
      {
      	System.Threading.Thread.Sleep(100);
      }
      

      } while (true);

      Regards, mav P.S.: "'Multiple exclamation marks,' he went on, shaking his head, 'are a sure sign of a diseased mind.'" (Terry Pratchett in "Eric"). ;P

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups