I work with an application that receives a file using TCP protocol, the application processes the file and then sends it using the same protocol, I receive the file without problems, my problem is when I try to send the file, because I need to send the file to another The application that listens on the dynamic port, the code that I use to send these files is as follows:
internal void Send(byte[] buffer)
{
TcpClient _client = null;
try
{
_client = new TcpClient(RemoteIPaddress, Dynamic_port);
if (_client != null)
{
NetworkStream _clienttStream = _client.GetStream();
_clienttStream.Write(buffer, 0, buffer.Length);
_clienttStream.Flush();
_clienttStream.Close();
_clienttStream = null;
}
}
catch
{
if (_client != null)
{
_client.Close();
_client = null;
}
}
}
The question is, how can I send a file via TCP to a remote machine using a dynamic port
source
share