aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Servers/UDPServerBase.cs
diff options
context:
space:
mode:
authorMW2007-05-19 14:08:58 +0000
committerMW2007-05-19 14:08:58 +0000
commitf5de37553d04b3a263ff54aca7e319550cba66ad (patch)
tree1c5e9e8d14c30d82e9fcb344f1d5fa8738677738 /OpenSim.Servers/UDPServerBase.cs
parentAdded a CheckSumServer (handles template checksum , so there is no longer the... (diff)
downloadopensim-SC_OLD-f5de37553d04b3a263ff54aca7e319550cba66ad.zip
opensim-SC_OLD-f5de37553d04b3a263ff54aca7e319550cba66ad.tar.gz
opensim-SC_OLD-f5de37553d04b3a263ff54aca7e319550cba66ad.tar.bz2
opensim-SC_OLD-f5de37553d04b3a263ff54aca7e319550cba66ad.tar.xz
Moved CheckSumServer (and added UDPServerBase ) to OpenSim.Servers
Diffstat (limited to 'OpenSim.Servers/UDPServerBase.cs')
-rw-r--r--OpenSim.Servers/UDPServerBase.cs74
1 files changed, 74 insertions, 0 deletions
diff --git a/OpenSim.Servers/UDPServerBase.cs b/OpenSim.Servers/UDPServerBase.cs
new file mode 100644
index 0000000..bdbc772
--- /dev/null
+++ b/OpenSim.Servers/UDPServerBase.cs
@@ -0,0 +1,74 @@
1using System;
2using System.Text;
3using System.IO;
4using System.Threading;
5using System.Net;
6using System.Net.Sockets;
7using System.Timers;
8using System.Reflection;
9using System.Collections;
10using System.Collections.Generic;
11using libsecondlife;
12using libsecondlife.Packets;
13
14namespace OpenSim.Servers
15{
16 public class UDPServerBase
17 {
18
19 public Socket Server;
20 protected IPEndPoint ServerIncoming;
21 protected byte[] RecvBuffer = new byte[4096];
22 protected byte[] ZeroBuffer = new byte[8192];
23 protected IPEndPoint ipeSender;
24 protected EndPoint epSender;
25 protected AsyncCallback ReceivedData;
26 protected int listenPort;
27
28 public UDPServerBase()
29 {
30 }
31
32 protected virtual void OnReceivedData(IAsyncResult result)
33 {
34 ipeSender = new IPEndPoint(IPAddress.Any, 0);
35 epSender = (EndPoint)ipeSender;
36 Packet packet = null;
37 int numBytes = Server.EndReceiveFrom(result, ref epSender);
38 int packetEnd = numBytes - 1;
39
40 packet = Packet.BuildPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
41
42
43
44 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
45 }
46
47 protected virtual void AddNewClient(Packet packet)
48 {
49 }
50
51 public void ServerListener()
52 {
53
54 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
55 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
56 Server.Bind(ServerIncoming);
57
58 ipeSender = new IPEndPoint(IPAddress.Any, 0);
59 epSender = (EndPoint)ipeSender;
60 ReceivedData = new AsyncCallback(this.OnReceivedData);
61 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
62 }
63
64
65 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
66 {
67 // find the endpoint for this circuit
68
69 }
70
71
72 }
73}
74