FreeNOS
UDPSocket.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __LIB_LIBNET_UDPSOCKET_H
19#define __LIB_LIBNET_UDPSOCKET_H
20
21#include <Types.h>
22#include "NetworkSocket.h"
23#include "NetworkQueue.h"
24#include "NetworkClient.h"
25
26class UDP;
27
43{
44 public:
45
49 UDPSocket(const u32 inode,
50 UDP *udp,
51 const ProcessID pid);
52
56 virtual ~UDPSocket();
57
63 const u16 getPort() const;
64
75 virtual FileSystem::Result read(IOBuffer & buffer,
76 Size & size,
77 const Size offset);
78
89 virtual FileSystem::Result write(IOBuffer & buffer,
90 Size & size,
91 const Size offset);
92
100 virtual bool canRead() const;
101
110
111 private:
112
115
118
121};
122
128#endif /* __LIB_LIBNET_UDPSOCKET_H */
Abstract Input/Output buffer.
Definition IOBuffer.h:38
Networking packet queue implementation.
Network socket represents a single logical connection on a protocol.
User Datagram Protocol (UDP) socket.
Definition UDPSocket.h:43
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Send UDP data.
Definition UDPSocket.cpp:77
u16 m_port
Local port.
Definition UDPSocket.h:117
const u16 getPort() const
Get associated local port.
Definition UDPSocket.cpp:39
virtual bool canRead() const
Check if the File has data ready for reading.
UDP * m_udp
UDP protocol instance.
Definition UDPSocket.h:114
virtual ~UDPSocket()
Destructor.
Definition UDPSocket.cpp:35
NetworkQueue m_queue
Incoming packet queue.
Definition UDPSocket.h:120
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Receive UDP data.
Definition UDPSocket.cpp:44
virtual FileSystem::Result process(const NetworkQueue::Packet *pkt)
Process incoming network packet.
User Datagram Protocol (UDP)
Definition UDP.h:42
u32 ProcessID
Process Identification Number.
Definition Types.h:140
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned short u16
Unsigned 16-bit number.
Definition Types.h:56
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
Result
Result code for filesystem Actions.
Definition FileSystem.h:53
Represents a network packet.