-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
43 lines (42 loc) · 1.42 KB
/
Copy pathProgram.cs
File metadata and controls
43 lines (42 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace SocketTest
{
public static class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter 1(Client) or 2(Server):");
int i = 0;
int.TryParse(Console.ReadLine(), out i);
if (i == 1)
{
Console.WriteLine("Enter reciver IP:");
string ip = Console.ReadLine();
Console.WriteLine("Enter File Path:");
string path = Console.ReadLine();
using (var clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
{
clientSocket.Connect(new IPEndPoint(IPAddress.Parse(ip), 10088));
clientSocket.SendBigFile(path);
clientSocket.Close();
}
Console.WriteLine("Send successfully!");
Console.WriteLine("Press any key to Exit...");
Console.ReadKey();
}
else if (i == 2)
{
SocketServer.Init();
Console.WriteLine("Press any key to Exit...");
Console.ReadKey();
SocketServer.Exit();
}
}
}
}