# C# Socket
# C# Socket
by jihoon kim
HTML
<style>
.MJXp-math.MJXp-display {
display:inline !important;
}
</style>
<div id="contents">
## Socket C#
### Server - Winform Version
```csharp
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
public static extern int SendMessage(IntPtr hwnd, int msg, int wparam, int lparam);
TcpListener serverSocket = new TcpListener(8888);
TcpClient clientSocket = default(TcpClient);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
delegate void appendStatusCallback(string text);
public void appendStatus(String v)
{
if (this.textBox1.InvokeRequired)
{
appendStatusCallback d = new appendStatusCallback(appendStatus);
this.Invoke(d, new object[] { v });
}
else
{
this.textBox1.AppendText(v+"\n");
}
}
private void StartServer()
{
int counter = 0;
serverSocket.Start();
appendStatus(" >> " + "Server Started");
counter = 0;
while (true)
{
counter += 1;
clientSocket = serverSocket.AcceptTcpClient();
//appendStatus(" >> " + "Client No:" + Convert.ToString(counter) + " started!");
...