I wrote a class to connect to a server using tcpclient.
I need to connect to the server and the connection must be open.Then i need to send request to the server again and again.But the problem is that i can communicate with the servet just for one time,the first time i connect to the server,send data and receive response,but when i want to receive data for another time,there won't be any response.some body help me please,whats the problem???
this is the class code i wrote:
----------------------------------------------------------------------
public class TCPAgent
{
TcpClient TCPconn = new TcpClient();
NetworkStream NetWorkStream;
public void Connect(string Server , int port)
{
TCPconn.Connect (Server, port);
NetWorkStream = TCPconn.GetStre am();
}
public string transfer(string SendCommand)
{
byte[] SendCmd = Encoding.ASCII. GetBytes(SendCo mmand);
NetWorkStream.W rite(SendCmd,0, SendCmd.Length) ;
StreamReader objSR = new StreamReader(TC Pconn.GetStream (), Encoding.ASCII) ;
return (objSR.ReadToEn d());
}
public string close
{
set
{
this.NetWorkStr eam.Close();
this.TCPconn.Cl ose();
}
}
}
1 3342 Banfa 9,065
Recognized Expert Moderator Expert
OK I am guessing here but I think it might be worth finding out what the server is doing. I think it may be possible that having handled a request the server is then closing the connection so that no more requests work. I think that you have to tell the server, somehow, to keep your connection live until you say otherwise.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: midnighthell |
last post by:
I'm using MemoryStream, and when I send this stream over the network with
TCP using NetworkStream , I must Deserialize it, but I don't how to convert
from NetworkStream to MemoryStream, I have tried something like that, but it
don't work:
System.Net.Sockets.NetworkStream netstream =TCPClient.GetStream();
MemoryStream memStrim=new...
|
by: Jim H |
last post by:
I have a UDP socket that sends out a request on a multicast socket and waits
for a response. This client is not listening on a multicast IP but the
local IP. The server (UNIX) responds to the sender's IP. Using debug files
on the server I see the server receive the request from my application on my
machine and I see the server send to the...
|
by: Mike |
last post by:
Hi,
We are in the process of evaluating a system that would allow us to receive data from third-parties and send data to partner companies. Our infrastructure includes Microsoft Navision, a SQL Server, and .NET 2.0. My idea would be to use web services with XML to fullfil the above requirements, but I have very little experience on web...
|
by: fabrizio.viggiani |
last post by:
I need to send a mail message to an SMTP server.
The .net framework provides System.Net.Mail namespace to send an email:
- Build a System.Net.Mail.MailMessage and send it using SmtpClient
The message that I have to send is already in the form of a MIME stream
(multipart, attachments and digitally signed), so using the classes of
the...
|
by: jaco.versfeld |
last post by:
Hi There,
I have a basic TCP client and TCP server in C++. The TCP client
connects to the server, and after a setup phase starts to transmit a
file to the TCP server using multiple packets (fixed amount of bytes,
except for the last packet). This is accomplished by using a for loop
and the "int send(socket, buffer, bufferlength, 0)"...
| |
by: Rich |
last post by:
Hello,
I am working on a python library for sending and receiving data from a Subaru's ECU (the fuel injection computer) via the OBD-II port and an OBD to USB cable, with the Subaru Select Monitor protocol. There are a few open source programs that do this already (http://romraider.com/ , http://jdash.sourceforge.net/ ,...
|
by: dtittle |
last post by:
Hi,
I am working on a C# app for a mobile 05 device that will send data to a server. I think I need to use the NetWorkStream to send it via TCP but I'm not sure how to do that. The book that I am using is not very clear on that subject. Can anyone help?
Thanks,
|
by: Airslash |
last post by:
Hello,
The problem is that my server is not receiving data.
The code below are the various classes I designed around sockets. It will be big...
I have run the code with the debugger, and I see in the debug output that the client connects to the server, the events get fired and the disconnect event gets fired as well.
I get confirmation...
|
by: kishoreforqns |
last post by:
how to download files (2mb>) using networkstream from a mailserver..
i can conenct to the mail server, list unread mails, and i can also retreive unread mails. but that till 1.5 mb. how to do this.. what concept i have to use.. how the server is sending the data..
now i am using the code given for retreive (RETR)
Thread.Sleep(100000);
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |