udpsocket.h
来自「跨操作系统的微型中间件」· C头文件 代码 · 共 63 行
H
63 行
/* File: UDPSocket.h Contains: Adds additional Socket functionality specific to UDP. */#ifndef __UDPSOCKET_H__#define __UDPSOCKET_H__#ifndef __Win32__#include <sys/socket.h>#include <sys/uio.h>#endif#include "Socket.h"class UDPSocket : public Socket{ public: //Another socket type flag (in addition to the ones defined in Socket.h). //The value of this can't conflict with those! enum { kWantsDemuxer = 0x0100 //UInt32 }; UDPSocket(); virtual ~UDPSocket() {} //Open OS_Error Open() { return Socket::Open(SOCK_DGRAM); } OS_Error SetRemoteAddr(UInt32 inRemoteAddr, UInt16 inRemotePort); OS_Error JoinMulticast(UInt32 inRemoteAddr); OS_Error LeaveMulticast(UInt32 inRemoteAddr); OS_Error SetTtl(UInt16 timeToLive); OS_Error SetMulticastInterface(UInt32 inLocalAddr); //returns an ERRNO OS_Error SendTo(const char* inBuffer, UInt32 inLength); OS_Error SendTo(UInt32 inRemoteAddr, UInt16 inRemotePort, void* inBuffer, UInt32 inLength); OS_Error RecvFrom(void* ioBuffer, UInt32 inBufLen, UInt32* outRecvLen); OS_Error RecvFrom(UInt32* outRemoteAddr, UInt16* outRemotePort, void* ioBuffer, UInt32 inBufLen, UInt32* outRecvLen); private: struct sockaddr_in m_theRemoteAddr; struct sockaddr_in fMsgAddr; // ?};#endif // __UDPSOCKET_H__
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?