Questions tagged [tcpclient]

.NET Framework class, providing client connections for TCP network services.

2541 questions
10
votes
5 answers

C# NetworkStream.Read oddity

Can anyone point out the flaw in this code? I'm retrieving some HTML with TcpClient. NetworkStream.Read() never seems to finish when talking to an IIS server. If I go use the Fiddler proxy instead, it works fine, but when talking directly to the…
3Dave
  • 28,657
  • 18
  • 88
  • 151
10
votes
1 answer

Simple TCPClient/Listener ("hello world") example

All I'm looking for is a simple TCPClient/Listener ("hello world") example. I'm a newbie and Microsoft TCPClient/Listener class examples are not what I am looking for. All I am looking is for the TCPClient to send a message "Hello world" and for a…
Benjamin Jones
  • 987
  • 4
  • 22
  • 50
10
votes
4 answers

Cancel C# 4.5 TcpClient ReadAsync by timeout

What would the proper way to cancel TcpClient ReadAsync operation by timeout and catch this timeout event in .NET 4.5? TcpClient.ReadTimeout seems to be applied to the sync Read only. UPDATE: Tried tro apply the approach desribed here Cancelling an…
miksh
  • 169
  • 1
  • 3
  • 10
10
votes
1 answer

How to detect a Socket Disconnect in C#

I'm working on a client/server relationship that is meant to push data back and forth for an indeterminate amount of time. The problem I'm attempting to overcome is on the client side, being that I cannot manage to find a way to detect a…
DigitalJedi805
  • 1,486
  • 4
  • 16
  • 41
10
votes
2 answers

Telnet IAC command answering

I'm trying to negotiate a telnet connection with a socket. The socket is working,but the server is telling me that thing: ÿýÿýÿûÿû login: The ÿýÿýÿûÿû means 255 253 1 255 253 31 255 251 1 255 251 3 I read all the RFC docs but I don't understand…
Cindy Broutin
  • 187
  • 1
  • 3
  • 10
9
votes
1 answer

SslStream equivalent of TcpClient.Available?

Based on the advice of @Len-Holgate in this question, I'm asynchronously requesting 0-byte reads, and in the callback, accept bytes the available bytes with synchronous reads, since I know the data is available and won't block. This seems so…
Jason Kleban
  • 20,024
  • 18
  • 75
  • 125
9
votes
2 answers

C# - TcpClient - Detecting end of stream?

I am trying to interface an ancient network camera to my computer and I am stuck at a very fundamental problem -- detecting the end of stream. I am using TcpClient to communicate with the camera and I can actually see it transmitting the command…
Hamza
  • 2,313
  • 7
  • 25
  • 33
9
votes
3 answers

Client fails to send data to TCP server in golang?

I have both TCP server and a client, Simple TCP server will just receive incoming data and print it and the client will be continuously creating a socket connection and send data to TCP server in a loop. The information I got is that if a TCP…
Albi
  • 1,705
  • 1
  • 17
  • 28
9
votes
1 answer

How to connect Flutter app to tcp socket server?

I had great difficulties to connect Flutter app to my network tcp socket on server. I know I have to use some sort intermediate option so translate data between tcp socket to flutter and Flutter to tcp socket. Any idea, info how do achieve this. And…
Nick
  • 4,163
  • 13
  • 38
  • 63
9
votes
4 answers

C# Why doesn't "Flush" force the bytes down the network stream?

I have a project where I'm trying to send a serialized object to the server, then wait for an "OK" or "ERROR" message to come back. I seem to be having a similar problem to th poster of : TcpClient send/close problem The issue is that the only way I…
Jerry
  • 4,507
  • 9
  • 50
  • 79
9
votes
3 answers

TcpClient: How do I close and reconnect it again?

Hello and thanks for your help. This time I would like to ask about TcpClient. I have a server program and I am writing a client program. This client uses TcpClient. It starts by creating a new client clientSocket=new TcpClient(); (By the way,…
KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
9
votes
5 answers

TcpListener is queuing connections faster than I can clear them

As I understand it, TcpListener will queue connections once you call Start(). Each time you call AcceptTcpClient (or BeginAcceptTcpClient), it will dequeue one item from the queue. If we load test our TcpListener app by sending 1,000 connections to…
Matt Brindley
  • 9,739
  • 7
  • 47
  • 51
9
votes
2 answers

Accept TCP Client Async

I've been making a server. I am using TcpListener.AcceptTcpClientAsync() in an async method, but I have no idea how to actually make it work. My code right now is: private static async void StartServer() { Console.WriteLine("S: Server started…
Ilan
  • 513
  • 2
  • 8
  • 24
9
votes
1 answer

Understanding the NetworkStream.EndRead()-example from MSDN

I tried to understand the MSDN example for NetworkStream.EndRead(). There are some parts that i do not understand. So here is the example (copied from MSDN): // Example of EndRead, DataAvailable and BeginRead. public static void…
jsf
  • 913
  • 3
  • 14
  • 22
9
votes
4 answers

Unable to connect from remote machine

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 { …
Allek
  • 373
  • 3
  • 6
  • 14