TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
anbu joseph
NA
20
1k
Connect & Copy File from Server DB to local intranet system
Jun 11 2020 4:59 AM
I want to connect the server using IP address and port and transfer the Rig Machine data files to my local machine.
It may be intranet based systems or remote systems. Please help me. I just tried this code, but error as
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll.
when it is reaching the line--socket.bind(ipEnd) below:
---------------------------------------------------------------------
{
string host; int port= 5040; host = Convert.ToString("192.162.0.47");
//IPAddress[] IPs = Dns.GetHostAddresses(host);
IPEndPoint ipEnd = new IPEndPoint(IPAddress.Parse(host), 5040);
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sock.Bind(ipEnd);
sock.Listen(100);
Socket clientSock = sock.Accept();
byte[] clientData = new byte[1024 * 5000];
string receivedPath = "Projects/";
//Socket clientSock = sock.Accept();
int receivedBytesLen = clientSock.Receive(clientData);
int fileNameLen = BitConverter.ToInt32(clientData, 0);
string fileName = Encoding.ASCII.GetString(clientData, 4, fileNameLen);
Console.WriteLine("Client:{0} connected & File {1} started received.", clientSock.RemoteEndPoint, fileName);
BinaryWriter bWrite = new BinaryWriter(File.Open(receivedPath + fileName, FileMode.Append)); ;
bWrite.Write(clientData, 4 + fileNameLen, receivedBytesLen - 4 - fileNameLen);
Console.WriteLine("File: {0} received & saved at path: {1}", fileName, receivedPath);
bWrite.Close();
clientSock.Close();
Console.ReadLine();
}
----------------------------------------------------
Please help me. Thanks a lot.
Reply
Answers (
1
)
Replace starting and ending characters of a string
Trying to change value of textbox.txt from a static method.