OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_UDP_UDP_SOCKET_H_ | 5 #ifndef NET_UDP_UDP_SOCKET_H_ |
6 #define NET_UDP_UDP_SOCKET_H_ | 6 #define NET_UDP_UDP_SOCKET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #if defined(OS_WIN) | 11 #if defined(OS_WIN) |
12 #include "net/udp/udp_socket_win.h" | 12 #include "net/udp/udp_socket_win.h" |
13 #elif defined(OS_POSIX) | 13 #elif defined(OS_POSIX) |
14 #include "net/udp/udp_socket_libevent.h" | 14 #include "net/udp/udp_socket_libevent.h" |
15 #endif | 15 #endif |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 | 18 |
19 // A client socket that uses UDP as the transport layer. | 19 // UDPSocket |
| 20 // Accessor API for a UDP socket in either client or server form. |
| 21 // |
| 22 // Client form: |
| 23 // In this case, we're connecting to a specific server, so the client will |
| 24 // usually use: |
| 25 // Connect(address) // Connect to a UDP server |
| 26 // Read/Write // Reads/Writes all go to a single destination |
| 27 // |
| 28 // Server form: |
| 29 // In this case, we want to read/write to many clients which are connecting |
| 30 // to this server. First the server 'binds' to an addres, then we read from |
| 31 // clients and write responses to them. |
| 32 // Example: |
| 33 // Bind(address/port) // Binds to port for reading from clients |
| 34 // RecvFrom/SendTo // Each read can come from a different client |
| 35 // // Writes need to be directed to a specific |
| 36 // // address. |
20 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
21 typedef UDPSocketWin UDPSocket; | 38 typedef UDPSocketWin UDPSocket; |
22 #elif defined(OS_POSIX) | 39 #elif defined(OS_POSIX) |
23 typedef UDPSocketLibevent UDPSocket; | 40 typedef UDPSocketLibevent UDPSocket; |
24 #endif | 41 #endif |
25 | 42 |
26 } // namespace net | 43 } // namespace net |
27 | 44 |
28 #endif // NET_UDP_UDP_SOCKET_H_ | 45 #endif // NET_UDP_UDP_SOCKET_H_ |
OLD | NEW |