Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Creating a TCP/IP Connection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BillB - 29 Feb 2008 15:56 GMT
Hi,

I'm new to C# and was wondering how I can create a TCP/IP connection.

I would like to be able to create a connection to a web server on a specific
port fire of some commands to it and then once I'm finished close the
connection again.
I'm looking for something similar to how HyperTerminal connects to an IP
address and allows you to type commands to it.

Any info is appreciated.
Nicholas Paldino [.NET/C# MVP] - 29 Feb 2008 16:26 GMT
Bill,

   Have you looked at the Socket class in the System.Net namespace?  It
will allow you to create the connection you are looking for.

   However, I wouldn't recommend that.  If you are connecting to a web
server, you want a higher level abstraction to issue commands and read the
responses from the server.  In this case, I would recommend using the
HttpWebRequest and HttpWebResponse classes, or the WebClient class, also in
the System.Net namespace.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hi,
>
[quoted text clipped - 7 lines]
>
> Any info is appreciated.
Jeroen Mostert - 29 Feb 2008 19:02 GMT
> I'm looking for something similar to how HyperTerminal connects to an IP
> address and allows you to type commands to it.

That's called Telnet.

Signature

J.

John Rivers - 01 Mar 2008 23:53 GMT
> Hi,
>
[quoted text clipped - 7 lines]
>
> Any info is appreciated.

System.Net.TcpClient

it is mostly a convenience class on top of Socket

I would spend a bit of extra time and use Sockets directly

TcpClient is horribly "encapsulated" and you usually end up needing a
feature that you can get easily if you use Socket directly
BillB - 03 Mar 2008 10:41 GMT
Hey
I was thinking of going down the Sockets route, was just looking for some
info about it.
My little test app is going to have connect and disconnect buttons, and a
few other buttons that will have some preloaded request to send to the
server, as far as i know i won't recieve anything back from the server
(going by what i get hen using HyperTerminal) the actual server is used to
control an intercom system so i am sending it connection requests and a few
other commands.

Thanks

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.