Reputation: 1329
I'm trying to make a simple program that connects to an irc client.
In another post on code review, I saw this line:
using (var irc = new TcpClient(_server, _port))
I have attempted to use this in my application but I get the error
TcpClient does not contain a constructor that takes 2 arguments
According to the MSDN docs TcpClient Constructor it should take string server, int port
parameters.
:
class IRCBot
{
private readonly string _server;
private readonly int _port;
public IRCBot (string server, int port)
{
_server = server;
_port = port;
}
public void ChannelConnect()
{
do
{
try
{
using (var irc = new TcpClient(_server, _port))
// Rest of code
}
Upvotes: 0
Views: 883
Reputation: 1320
If you are using .NET Core try this:
// Create the client.
TcpClient client = new TcpClient();
// Connect to the server.
await client.ConnectAsync(_server, _port);
Upvotes: 1