Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(974)

Delta Between Two Patch Sets: src/pkg/net/fd_windows.go

Issue 3136042: code review 3136042: net: add ReadFrom and WriteTo windows version. (Closed)
Left Patch Set: code review 3136042: net: add ReadFrom and WriteTo windows version. Created 13 years, 4 months ago
Right Patch Set: code review 3136042: net: add ReadFrom and WriteTo windows version. Created 13 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/syscall/syscall_windows.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package net 5 package net
6 6
7 import ( 7 import (
8 "os" 8 "os"
9 "sync" 9 "sync"
10 "syscall" 10 "syscall"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 fd.incref() 254 fd.incref()
255 defer fd.decref() 255 defer fd.decref()
256 if fd.sysfile == nil { 256 if fd.sysfile == nil {
257 return 0, nil, os.EINVAL 257 return 0, nil, os.EINVAL
258 } 258 }
259 // Submit receive request. 259 // Submit receive request.
260 var pckt ioPacket 260 var pckt ioPacket
261 pckt.c = fd.cr 261 pckt.c = fd.cr
262 var done uint32 262 var done uint32
263 flags := uint32(0) 263 flags := uint32(0)
264 » e := syscall.WSARecvFrom(uint32(fd.sysfd), newWSABuf(p), 1, &done, &flag s, &sa, &pckt.o, nil) 264 » var rsa syscall.RawSockaddrAny
265 » l := int32(unsafe.Sizeof(rsa))
266 » e := syscall.WSARecvFrom(uint32(fd.sysfd), newWSABuf(p), 1, &done, &flag s, &rsa, &l, &pckt.o, nil)
265 switch e { 267 switch e {
266 case 0: 268 case 0:
267 // IO completed immediately, but we need to get our completion m essage anyway. 269 // IO completed immediately, but we need to get our completion m essage anyway.
268 case syscall.ERROR_IO_PENDING: 270 case syscall.ERROR_IO_PENDING:
269 // IO started, and we have to wait for it's completion. 271 // IO started, and we have to wait for it's completion.
270 default: 272 default:
271 » » return 0, nil, &OpError{"WSARecvfrom", fd.net, fd.laddr, os.Errn o(e)} 273 » » return 0, nil, &OpError{"WSARecvFrom", fd.net, fd.laddr, os.Errn o(e)}
272 } 274 }
273 // Wait for our request to complete. 275 // Wait for our request to complete.
274 r := <-pckt.c 276 r := <-pckt.c
275 if r.errno != 0 { 277 if r.errno != 0 {
276 » » err = &OpError{"WSARecvfrom", fd.net, fd.laddr, os.Errno(r.errno )} 278 » » err = &OpError{"WSARecvFrom", fd.net, fd.laddr, os.Errno(r.errno )}
277 } 279 }
278 n = int(r.qty) 280 n = int(r.qty)
281 sa, _ = rsa.Sockaddr()
279 return 282 return
280 } 283 }
281 284
282 func (fd *netFD) Write(p []byte) (n int, err os.Error) { 285 func (fd *netFD) Write(p []byte) (n int, err os.Error) {
283 if fd == nil { 286 if fd == nil {
284 return 0, os.EINVAL 287 return 0, os.EINVAL
285 } 288 }
286 fd.wio.Lock() 289 fd.wio.Lock()
287 defer fd.wio.Unlock() 290 defer fd.wio.Unlock()
288 fd.incref() 291 fd.incref()
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 defer fd.wio.Unlock() 326 defer fd.wio.Unlock()
324 fd.incref() 327 fd.incref()
325 defer fd.decref() 328 defer fd.decref()
326 if fd.sysfile == nil { 329 if fd.sysfile == nil {
327 return 0, os.EINVAL 330 return 0, os.EINVAL
328 } 331 }
329 // Submit send request. 332 // Submit send request.
330 var pckt ioPacket 333 var pckt ioPacket
331 pckt.c = fd.cw 334 pckt.c = fd.cw
332 var done uint32 335 var done uint32
333 336 » e := syscall.WSASendto(uint32(fd.sysfd), newWSABuf(p), 1, &done, 0, sa, &pckt.o, nil)
334 » e := syscall.WSASendTo(uint32(fd.sysfd), newWSABuf(p), 1, &done, 0, sa, &pckt.o, nil)
335 switch e { 337 switch e {
336 case 0: 338 case 0:
337 // IO completed immediately, but we need to get our completion m essage anyway. 339 // IO completed immediately, but we need to get our completion m essage anyway.
338 case syscall.ERROR_IO_PENDING: 340 case syscall.ERROR_IO_PENDING:
339 // IO started, and we have to wait for it's completion. 341 // IO started, and we have to wait for it's completion.
340 default: 342 default:
341 » » return 0, &OpError{"WSASend", fd.net, fd.laddr, os.Errno(e)} 343 » » return 0, &OpError{"WSASendTo", fd.net, fd.laddr, os.Errno(e)}
342 } 344 }
343 // Wait for our request to complete. 345 // Wait for our request to complete.
344 r := <-pckt.c 346 r := <-pckt.c
345 if r.errno != 0 { 347 if r.errno != 0 {
346 » » err = &OpError{"WSASend", fd.net, fd.laddr, os.Errno(r.errno)} 348 » » err = &OpError{"WSASendTo", fd.net, fd.laddr, os.Errno(r.errno)}
347 } 349 }
348 n = int(r.qty) 350 n = int(r.qty)
349 return 351 return
350 } 352 }
351 353
352 func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err os. Error) { 354 func (fd *netFD) accept(toAddr func(syscall.Sockaddr) Addr) (nfd *netFD, err os. Error) {
353 if fd == nil || fd.sysfile == nil { 355 if fd == nil || fd.sysfile == nil {
354 return nil, os.EINVAL 356 return nil, os.EINVAL
355 } 357 }
356 fd.incref() 358 fd.incref()
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 e := syscall.WSAStartup(uint32(0x101), &d) 438 e := syscall.WSAStartup(uint32(0x101), &d)
437 if e != 0 { 439 if e != 0 {
438 initErr = os.NewSyscallError("WSAStartup", e) 440 initErr = os.NewSyscallError("WSAStartup", e)
439 } 441 }
440 } 442 }
441 443
442 func (fd *netFD) dup() (f *os.File, err os.Error) { 444 func (fd *netFD) dup() (f *os.File, err os.Error) {
443 // TODO: Implement this 445 // TODO: Implement this
444 return nil, os.NewSyscallError("dup", syscall.EWINDOWS) 446 return nil, os.NewSyscallError("dup", syscall.EWINDOWS)
445 } 447 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b