ExSocket
Search…
Getting Started

Client Side

1
using CodeReaper;
2
3
// define exSocket object
4
exSocket sckClient = new exSocket();
5
6
public Form1()
7
{
8
InitializeComponent();
9
10
// Set default IP and Port
11
sckClient.remoteIP = "127.0.0.1";
12
sckClient.remotePort = 9001;
13
14
// Link object with event handler
15
sckClient.onConnect += SckClient_onConnect;
16
sckClient.onDisconnect += SckClient_onDisconnect;
17
sckClient.onDataArrival += SckClient_onDataArrival;
18
19
// Set ConnectInterval (ms)
20
sckClient.ConnectInterval = 1000;
21
// Set AutoConnectEnable flag to true
22
sckClient.AutoConnectEnable = true;
23
}
24
25
private void SckClient_onConnect(object sender)
26
{
27
// Connected!
28
}
29
30
private void SckClient_onDisconnect(object sender)
31
{
32
// Disconnected!
33
}
34
35
private void SckClient_onDataArrival(object sender, byte[] Data, int bytesRead)
36
{
37
MessageBox.Show(Encoding.UTF8.GetString(Data));
38
}
39
Copied!

Server Side

1
using CodeReaper;
2
3
// define exSocket object
4
exSocket sckServer = new exSocket();
5
6
public Form1()
7
{
8
InitializeComponent();
9
10
// Set Local Port to listen.
11
sckServer.LocalPort = 9001;
12
13
sckServer.onConnect += SckServer_onConnect;
14
sckServer.onDisconnect += SckServer_onDisconnect;
15
sckServer.onDataArrival += SckServer_onDataArrival;
16
17
// call Listen()
18
sckServer.Listen();
19
}
20
21
private void SckServer_onConnect(object sender)
22
{
23
// Connected!
24
}
25
26
private void SckServer_onDisconnect(object sender)
27
{
28
// Disconnected!
29
}
30
31
private void SckServer_onDataArrival(object sender, byte[] Data, int bytesRead)
32
{
33
MessageBox.Show(Encoding.UTF8.GetString(Data));
34
}
35
Copied!

How to send data

1
now working....
Copied!
Last modified 2yr ago