473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

how to make TCP Client accepts Host?

My TCPClient should:

1.accepts host, port and a text string.
2.connects to a host/port and sends the string (+ two lines feeds \r\n\r\n )when you click a button.
3.then reads the results and puts the results back in a text box.


The problem that i get a result of the port and string , BUT I DON'T GET ANYTHING ABOUT THE HOST.

This is what i've got so far:

Expand|Select|Wrap|Line Numbers
  1.         private void button1_Click(object sender, EventArgs e)
  2.         {
  3.  
  4.             string port = port1.Text;
  5.             int myParsedInt = Int32.Parse(port);
  6.             System.Net.IPAddress[] adresslist = Dns.GetHostAddresses(host1.Text);
  7.  
  8.             Socket connectSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
  9.             connectSocket.Connect(adresslist[0], myParsedInt);
  10.             System.IO.StreamReader connectionRead = new System.IO.StreamReader(new NetworkStream(connectSocket));
  11.  
  12.             connectSocket.Send(System.Text.Encoding.UTF8.GetBytes(sendText.Text + "\r\n"));
  13.             while (connectionRead.Peek() >= 0)
  14.             {
  15.                 this.textOutput.AppendText(connectionRead.ReadLine() + "\r\n");
  16.  
  17.  
  18.             }
  19.  
  20.  
  21.             connectSocket.Close();
  22.         }
Sep 26 '13 #1
0 1155

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: ian maclure | last post by:
I'm writing a client-server app. Client controls Server which in turn configures and controls a bunch of hardware. I want to be able to start the server from my client. Now in C/C++ one could...
4
by: Little Monster | last post by:
Hi all, new to this ng and trying to run MySQL for the first time ever. The box runs Slackware 9.0 on a Duron, the version MySQL is "mysql-3.23.56-i386-1" as supplied with the distro. Starting...
7
by: Gooshi | last post by:
Is it possible to write a dead simple html chat client ie one form that can be accessed by two people : ie a form that has two text areas - one for me to write to - one for another person to...
1
by: Mark | last post by:
Here is a description of automatic client reroute in DB2 V8.2 "The automatic client reroute feature allows client applications to recover from a loss of communication with the server so that they...
1
by: Erich | last post by:
Hi, everybody! I would like my WebApp (ASP.NET) writes a text-file in my Web Host, so I could download it and import it to another application. Does anybody know how can I write a text file...
7
by: Mike Stephens | last post by:
How can I make a usercontrol host other controls, such as the Groupbox and Panel.
6
by: Marc | last post by:
How could I directly trigger a very simple on localhost and a known port listening server from my internet browser client? Local host means the little server would be running on the client machine,...
1
by: Alnur | last post by:
hi how can i make client SOAP in vb.net plsss i rily nid your help
2
by: HeMan_Speaks | last post by:
I m currently developing a java based application and want to know how can i make client access database located on the server?
5
by: Simon | last post by:
I heard that we could do that by using AJAX. Could anybody share how to do it? Thanks.
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.