tcpclient

Reading information from a port waits even though data available

[亡魂溺海] 提交于 2019-12-10 11:35:36
问题 I am having a problem sending information down a socket and receiving a response. I have a demo program which is performing correctly so I know it is not an issue with the client on the other end. The requestData is sent and the client acts correctly and responds, but my code never exits the loop in read response. Could the client be responding before I am listening? How can I make sure I never miss an incoming message? networkStream = tcpClient.GetStream(); StreamWriter clientStreamWriter =

How do i send an email when i already have it as a string?

女生的网名这么多〃 提交于 2019-12-10 10:27:52
问题 Effectively I'm trying to send some template emails so that I can test a few components that handle reading from mailboxes. I could just load up outlook and send a couple of emails but I'm looking to find a solution that can read thousands of emails at a time so I need to bulk send these templates t test the reading code. When I say bulk send ... I have about 10 to 15 templates (varies) and I want to send about 1,000 copies of each to the given mailbox. Now here's th sticking point ... I

.NET TcpClient/NetworkStream implementation that supports async operations and respects timeouts

孤者浪人 提交于 2019-12-10 05:16:25
问题 Based on the number of questions, forum posts, etc, it appears that the TcpClient/NetworkStream implementation in the BCL lacks decent support for cancelling IO operations. With the addition of Async methods in .NET 4.5, this lack of cancellation (or decent timeout support) makes things even more frustrating since it becomes even more complicated (nigh on impossible) to cancel a task that refuses to monitor its CancellationToken while performing IO. I have seen many implementations that spin

Unable to connect from remote machine

≡放荡痞女 提交于 2019-12-10 03:32:00
问题 I have some kind of problem and I can't check this at home if its working or not. Here is the code using System; using System.Net; using System.Net.Sockets; using System.Threading; using System.IO; using System.Net.Security; class Program { private static IPAddress ipAddress = IPAddress.Parse("127.0.0.1"); private static int port = 6000; private static string data = null; static void Main(string[] args) { Thread thread = new Thread(new ThreadStart(receiveThread)); thread.Start(); Console

Is it possible to convert between Socket and TcpClient objects?

╄→гoц情女王★ 提交于 2019-12-10 02:09:55
问题 Here's another C#/.NET question based merely on curiousity more than an immediate need ... If you had a Socket instance and you wanted to wrap it in the higher-level TcpClient class, is that possible and how would you do it? Conversely if you have an instance of TcpClient , is it possible to get the underlying Socket ? 回答1: If you had a Socket instance and you wanted to wrap it in the higher-level TcpClient class, is that possible and how would you do it? Socket socket = ...; TcpClient client

Tcp Client two way communication help

若如初见. 提交于 2019-12-09 07:19:55
问题 I want to communicate between two applications or winforms in C# using clients and server its like i want a server continiously listening to incoming messages from a client or clients and when the msg is received i want to reply back to the client that sent the information for processing can any one help with code example 回答1: Sounds like a good case for WCF using netTcpBinding in an intranet environment! :-) Check out these intros to WCF: Getting started with WCF WCF Templates and Tools WCF

Indy TCP - Read data in a loop

南楼画角 提交于 2019-12-09 05:01:44
问题 A TCP server is sending data frames continuosly every 8ms. I want to program a client able to receive these data frames. Is there any procedure in Indy 9 to know if there is data available in the buffer? My current programs is the following (I am using a Thread): procedure TThreadRead.Execute; var buffer: array [0..755] of byte; //s1: string; //i: integer; begin IdTCPClient1.RecvBufferSize:= 756; IdTCPClient1.Connect; while Terminated = false do begin if IdTCPClient1.InputBuffer.Size = 0 then

TcpClient - An existing connection was forcibly closed by the remote host

ⅰ亾dé卋堺 提交于 2019-12-09 00:42:51
问题 The Info I have been developing a web http server in c# and decided to add a remote console feature. The console can be used from any location and uses a TcpListener (web server) and a TcpClient (remote console) to send commands and functions through. The Code This is what my server looks like: TcpListener consoleListener = new TcpListener(consolePort); consoleListener.Start(); byte[] bytes = new Byte[256]; string data = null; while (true) { TcpClient client = consoleListener.AcceptTcpClient(

NetworkStream BeginRead / EndRead

◇◆丶佛笑我妖孽 提交于 2019-12-08 23:08:28
I'm really new to C# programming and I'm developing an application based on a TcpClient. I would like to know how to use BeginRead & EndRead, I've already read MSN documentation but doesn't help. I've this : private void Send() { TcpClient _client = new TcpClient("host", 80); NetworkStream ns = _client.GetStream(); ns.Flush(); / ... ns.Write(buffer, 0, buffer.Length); int BUFFER_SIZE = 1024; byte[] received = new byte[BUFFER_SIZE]; ns.BeginRead(received, 0, 0, new AsyncCallback(OnBeginRead), ns); } private void OnBeginRead(IAsyncResult ar) { NetworkStream ns = (NetworkStream)ar.AsyncState; int

Reading from same SslStream simultaneously?

江枫思渺然 提交于 2019-12-08 12:22:59
问题 I am currently reading XML data from a SslStream. The stream is coming from a TcpClient object. using (XmlReader r = XmlReader.Create(sslStream, new XmlReaderSettings() { Async = true })) { while (await r.ReadAsync()) { ResetStream = false; switch (r.NodeType) { case XmlNodeType.XmlDeclaration: ... break; case XmlNodeType.Element: ... Additionally I would like to read every single bit and byte from the TcpClient directly regardless whether it is XML data or not. How can I read the same stream