So in the old .NET you were able to initialize a new instance of the TcpClient class and connect to the specified port on the specified host using TcpClient(string, int). That no longer works for TcpClient in .NET core and I'm wondering if there is a replacement or some other way to do the same thing in core. I read the documentation, but maybe I'm missing something or there is a new, better way of going about this.
Also I'm going to use the GetStream method that works for both versions of TcpClient to load the stream into a NetworkStream.
The TcpClient class provides simple methods for connecting, sending, and receiving stream data over a network in synchronous blocking mode. In order for TcpClient to connect and exchange data, a TcpListener or Socket created with the TCP ProtocolType must be listening for incoming connection requests.
The CLI and Host classes for the TCP Client is practically identical to the TCP Server, the full version is attached and downloadable.
To summarize, the service uses TcpListener and TcpClient objects to hide the complexity of raw socket programming, and uses the new AcceptTcpClientAsync method in conjunction with the new async and await keywords to hide the complexity of asynchronous programming.
Every time TCP Server developed using .Net Core was on top in performance as compared to other platforms. So no one should have doubt on .Net Core Performance. I would also like to share a comment on one of your post which was related to handling thousands of requests using Java The above comment describes the Dotnet Core Performance over rxjava.
As per the source code, you can connect with:
public Task ConnectAsync(IPAddress address, int port)
Or one of the overloads.
And the GetStream you need, at line 151:
public NetworkStream GetStream()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With