Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: runtime/bin/socket.h

Issue 85993002: Add UDP support to dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_SOCKET_H_ 5 #ifndef BIN_SOCKET_H_
6 #define BIN_SOCKET_H_ 6 #define BIN_SOCKET_H_
7 7
8 #include "bin/builtin.h" 8 #include "bin/builtin.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 #include "bin/dartutils.h" 10 #include "bin/dartutils.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 int GetType() { 59 int GetType() {
60 if (addr_.ss.ss_family == AF_INET6) return TYPE_IPV6; 60 if (addr_.ss.ss_family == AF_INET6) return TYPE_IPV6;
61 return TYPE_IPV4; 61 return TYPE_IPV4;
62 } 62 }
63 63
64 const char* as_string() const { return as_string_; } 64 const char* as_string() const { return as_string_; }
65 const RawAddr& addr() const { return addr_; } 65 const RawAddr& addr() const { return addr_; }
66 66
67 static intptr_t GetAddrLength(const RawAddr* addr) { 67 static intptr_t GetAddrLength(const RawAddr* addr) {
68 ASSERT(addr->ss.ss_family == AF_INET || addr->ss.ss_family == AF_INET6);
68 return addr->ss.ss_family == AF_INET6 ? 69 return addr->ss.ss_family == AF_INET6 ?
69 sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in); 70 sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in);
70 } 71 }
71 72
72 static int16_t FromType(int type) { 73 static int16_t FromType(int type) {
73 if (type == TYPE_ANY) return AF_UNSPEC; 74 if (type == TYPE_ANY) return AF_UNSPEC;
74 if (type == TYPE_IPV4) return AF_INET; 75 if (type == TYPE_IPV4) return AF_INET;
75 ASSERT(type == TYPE_IPV6 && "Invalid type"); 76 ASSERT(type == TYPE_IPV6 && "Invalid type");
76 return AF_INET6; 77 return AF_INET6;
77 } 78 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 enum SocketRequest { 160 enum SocketRequest {
160 kLookupRequest = 0, 161 kLookupRequest = 0,
161 kListInterfacesRequest = 1, 162 kListInterfacesRequest = 1,
162 kReverseLookupRequest = 2, 163 kReverseLookupRequest = 2,
163 }; 164 };
164 165
165 static bool Initialize(); 166 static bool Initialize();
166 static intptr_t Available(intptr_t fd); 167 static intptr_t Available(intptr_t fd);
167 static int Read(intptr_t fd, void* buffer, intptr_t num_bytes); 168 static int Read(intptr_t fd, void* buffer, intptr_t num_bytes);
168 static int Write(intptr_t fd, const void* buffer, intptr_t num_bytes); 169 static int Write(intptr_t fd, const void* buffer, intptr_t num_bytes);
170 static int SendTo(intptr_t fd, const void* buffer, intptr_t num_bytes,
171 RawAddr addr);
172 static int RecvFrom(intptr_t fd, void* buffer, intptr_t num_bytes,
173 RawAddr* addr);
169 static intptr_t Create(RawAddr addr); 174 static intptr_t Create(RawAddr addr);
170 static intptr_t Connect(intptr_t fd, RawAddr addr, const intptr_t port); 175 static intptr_t Connect(intptr_t fd, RawAddr addr, const intptr_t port);
171 static intptr_t CreateConnect(RawAddr addr, 176 static intptr_t CreateConnect(RawAddr addr,
172 const intptr_t port); 177 const intptr_t port);
178 static intptr_t CreateBindDatagram(RawAddr* addr, intptr_t port);
173 static intptr_t GetPort(intptr_t fd); 179 static intptr_t GetPort(intptr_t fd);
174 static SocketAddress* GetRemotePeer(intptr_t fd, intptr_t* port); 180 static SocketAddress* GetRemotePeer(intptr_t fd, intptr_t* port);
175 static void GetError(intptr_t fd, OSError* os_error); 181 static void GetError(intptr_t fd, OSError* os_error);
176 static int GetType(intptr_t fd); 182 static int GetType(intptr_t fd);
177 static intptr_t GetStdioHandle(intptr_t num); 183 static intptr_t GetStdioHandle(intptr_t num);
178 static void Close(intptr_t fd); 184 static void Close(intptr_t fd);
179 static bool SetNonBlocking(intptr_t fd); 185 static bool SetNonBlocking(intptr_t fd);
180 static bool SetBlocking(intptr_t fd); 186 static bool SetBlocking(intptr_t fd);
187 static bool GetNoDelay(intptr_t fd, bool* enabled);
181 static bool SetNoDelay(intptr_t fd, bool enabled); 188 static bool SetNoDelay(intptr_t fd, bool enabled);
189 static bool GetMulticastLoop(intptr_t fd, bool* enabled);
190 static bool SetMulticastLoop(intptr_t fd, bool enabled);
191 static bool GetMulticastTTL(intptr_t fd, int* value);
192 static bool SetMulticastTTL(intptr_t fd, int value);
193 static bool GetBroadcast(intptr_t fd, bool* value);
194 static bool SetBroadcast(intptr_t fd, bool value);
195 static bool JoinMulticast(intptr_t fd, RawAddr* addr, int interfaceIndex);
196 static bool LeaveMulticast(intptr_t fd, RawAddr* addr, int interfaceIndex);
182 197
183 // Perform a hostname lookup. Returns a AddressList of SocketAddress's. 198 // Perform a hostname lookup. Returns a AddressList of SocketAddress's.
184 static AddressList<SocketAddress>* LookupAddress(const char* host, 199 static AddressList<SocketAddress>* LookupAddress(const char* host,
185 int type, 200 int type,
186 OSError** os_error); 201 OSError** os_error);
202
187 static bool ReverseLookup(RawAddr addr, 203 static bool ReverseLookup(RawAddr addr,
188 char* host, 204 char* host,
189 intptr_t host_len, 205 intptr_t host_len,
190 OSError** os_error); 206 OSError** os_error);
191 207
192 static bool ParseAddress(int type, const char* address, RawAddr* addr); 208 static bool ParseAddress(int type, const char* address, RawAddr* addr);
209 static bool FormatNumericAddress(RawAddr* addr, char* address, int len);
193 210
194 // List interfaces. Returns a AddressList of InterfaceSocketAddress's. 211 // List interfaces. Returns a AddressList of InterfaceSocketAddress's.
195 static AddressList<InterfaceSocketAddress>* ListInterfaces( 212 static AddressList<InterfaceSocketAddress>* ListInterfaces(
196 int type, 213 int type,
197 OSError** os_error); 214 OSError** os_error);
198 215
199 static CObject* LookupRequest(const CObjectArray& request); 216 static CObject* LookupRequest(const CObjectArray& request);
200 static CObject* ListInterfacesRequest(const CObjectArray& request); 217 static CObject* ListInterfacesRequest(const CObjectArray& request);
201 static CObject* ReverseLookupRequest(const CObjectArray& request); 218 static CObject* ReverseLookupRequest(const CObjectArray& request);
202 219
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 251
235 private: 252 private:
236 DISALLOW_ALLOCATION(); 253 DISALLOW_ALLOCATION();
237 DISALLOW_IMPLICIT_CONSTRUCTORS(ServerSocket); 254 DISALLOW_IMPLICIT_CONSTRUCTORS(ServerSocket);
238 }; 255 };
239 256
240 } // namespace bin 257 } // namespace bin
241 } // namespace dart 258 } // namespace dart
242 259
243 #endif // BIN_SOCKET_H_ 260 #endif // BIN_SOCKET_H_
OLDNEW
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | runtime/bin/socket.cc » ('j') | sdk/lib/io/socket.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698