Hello,
I want to send a file via tcp/ip.
I found this code here:
public void Send(Socket socket, byte[] buffer, int offset, int size, int timeout)
{
int port = Convert.ToInt32(txtPort.Text);
string host = txtIP.Text;
IPHostEntry address = Dns.GetHostEntry(host);
IPEndPoint ipe = new IPEndPoint(address.AddressList[0], port);
int sent = 0;
using (Socket sock = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp))
{
try
{
sock.Connect(ipe);
MessageBox.Show("Conectado");
sent += socket.Send(buffer, offset + sent, size - sent, SocketFlags.None);
}
catch ( Exception ex)
{
MessageBox.Show(ex.Message);
}
}
But when i run the program i got an error:
No connection could be made because the target machine actively refused it
The other computer its say: it is connected to my PC, but nothing happens
I just want to send a file
What I have tried:
C#, TCP/IP, error trying to send a file from my pc to another