|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #include "nsUDPSocketProvider.h" |
|
6 |
|
7 #include "nspr.h" |
|
8 |
|
9 NS_IMPL_ISUPPORTS(nsUDPSocketProvider, nsISocketProvider) |
|
10 |
|
11 nsUDPSocketProvider::~nsUDPSocketProvider() |
|
12 { |
|
13 } |
|
14 |
|
15 NS_IMETHODIMP |
|
16 nsUDPSocketProvider::NewSocket(int32_t aFamily, |
|
17 const char *aHost, |
|
18 int32_t aPort, |
|
19 nsIProxyInfo *aProxy, |
|
20 uint32_t aFlags, |
|
21 PRFileDesc * *aFileDesc, |
|
22 nsISupports **aSecurityInfo) |
|
23 { |
|
24 NS_ENSURE_ARG_POINTER(aFileDesc); |
|
25 |
|
26 PRFileDesc* udpFD = PR_OpenUDPSocket(aFamily); |
|
27 if (!udpFD) |
|
28 return NS_ERROR_FAILURE; |
|
29 |
|
30 *aFileDesc = udpFD; |
|
31 return NS_OK; |
|
32 } |
|
33 |
|
34 NS_IMETHODIMP |
|
35 nsUDPSocketProvider::AddToSocket(int32_t aFamily, |
|
36 const char *aHost, |
|
37 int32_t aPort, |
|
38 nsIProxyInfo *aProxy, |
|
39 uint32_t aFlags, |
|
40 struct PRFileDesc * aFileDesc, |
|
41 nsISupports **aSecurityInfo) |
|
42 { |
|
43 // does not make sense to strap a UDP socket onto an existing socket |
|
44 NS_NOTREACHED("Cannot layer UDP socket on an existing socket"); |
|
45 return NS_ERROR_UNEXPECTED; |
|
46 } |