DustinS 0 Newbie Poster

I made client & server programs in C# based on this example code.

c# client program:

IPHostEntry ip = Dns.GetHostEntry(tbServer.Text);//"MyComputer-MSI"
string addr = ip.AddressList[0].ToString();
TcpClient clientSocket = new TcpClient(addr, 1234);
At the last line above, I got the message:

An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
Additional information: No connection could be made because the target machine actively refused it
I made sure both programs (Client.exe and Server.exe) were allowed by Windows Firewall. No other antivirus currently enabled (as far as I know).

I've tried several different versions of this c# code from various message boards with the same result.

I went into Windows Firewall and gave the c# program (Client.exe) every permission I could find on the regular and advanced settings.

This Python code works fine with the c# server program (as well as with simple Python server code):

import socket
port = 1234 # The same port as used by the server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((socket.gethostname(), port))
s.sendall(b'Hello, world')

Dustin

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.