aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.Servers/UDPServerBase.cs
diff options
context:
space:
mode:
authorMW2007-05-24 12:35:32 +0000
committerMW2007-05-24 12:35:32 +0000
commitf95b6081cba084d1b067acea99c0effa2b3bf42c (patch)
tree7a7ab4aa037f75afa54f403c701a735acb101575 /Common/OpenSim.Servers/UDPServerBase.cs
parentDie ServiceManager! (Not really Gareth, just the old directory, new directory... (diff)
downloadopensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.zip
opensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.gz
opensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.bz2
opensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.xz
Renamed the new Directories. (removed the "-Source" from the end of them)
Diffstat (limited to 'Common/OpenSim.Servers/UDPServerBase.cs')
-rw-r--r--Common/OpenSim.Servers/UDPServerBase.cs68
1 files changed, 68 insertions, 0 deletions
diff --git a/Common/OpenSim.Servers/UDPServerBase.cs b/Common/OpenSim.Servers/UDPServerBase.cs
new file mode 100644
index 0000000..a308052
--- /dev/null
+++ b/Common/OpenSim.Servers/UDPServerBase.cs
@@ -0,0 +1,68 @@
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 public Socket Server;
19 protected IPEndPoint ServerIncoming;
20 protected byte[] RecvBuffer = new byte[4096];
21 protected byte[] ZeroBuffer = new byte[8192];
22 protected IPEndPoint ipeSender;
23 protected EndPoint epSender;
24 protected AsyncCallback ReceivedData;
25 protected int listenPort;
26
27 public UDPServerBase(int port)
28 {
29 listenPort = port;
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 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
43 }
44
45 protected virtual void AddNewClient(Packet packet)
46 {
47 }
48
49 public virtual void ServerListener()
50 {
51
52 ServerIncoming = new IPEndPoint(IPAddress.Any, listenPort);
53 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
54 Server.Bind(ServerIncoming);
55
56 ipeSender = new IPEndPoint(IPAddress.Any, 0);
57 epSender = (EndPoint)ipeSender;
58 ReceivedData = new AsyncCallback(this.OnReceivedData);
59 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
60 }
61
62 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
63 {
64
65 }
66 }
67}
68