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