00001
00002
00003
00004
00005
00006
00007 #ifndef _UDPEndpoint_H_
00008 #define _UDPEndpoint_H_
00009
00010
00011
00012
00013
00014
00015 #include "IPEndpoint.h"
00016 #include <UDPEndpointMsg.h>
00017
00018 class UDPEndpoint : public IPEndpoint
00019 {
00020 public:
00021 UDPEndpoint(int sendBufferSize = 2048, int receiveBufferSize=2048);
00022
00023 ~UDPEndpoint();
00024
00025
00026 int bind(int listenPort);
00027
00028
00029
00030 int bind(int listenPort, char* address, int sendPort);
00031 int bind(Port listenPort, IPAddress address, Port sendPort);
00032
00033
00034 int send(int size);
00035
00036
00037 int send(int size, char* addr, int sPort);
00038
00039
00040 int send(void* data,int size);
00041
00042
00043 int send(void* data,int size, char* address,int port);
00044
00045
00046 int send(void* data,int size, IPAddress address, int port);
00047
00048
00049 virtual void onReceive(void* data,int size);
00050
00051
00052 virtual void onClose();
00053 virtual void onSendingDone();
00054
00055
00056 void close();
00057
00058 const char* getErrorString(UDPEndpointError error);
00059 const char* getErrorString();
00060
00061 virtual void sendCont(antEnvMsg* msg);
00062 virtual void receiveCont(antEnvMsg* msg);
00063 virtual void closeCont(antEnvMsg* msg);
00064
00065 protected:
00066 IPAddress ipOfLastPackage;
00067
00068 private:
00069 IPAddress address;
00070 Port sendPort;
00071 Port listenPort;
00072 void startReceiving();
00073
00074 };
00075
00076
00077
00078 #endif