X Tutup
Skip to content

Commit ef9217e

Browse files
neelancebradfitz
authored andcommitted
net: add js/wasm architecture
This commit adds the js/wasm architecture to the net package. The net package is not supported by js/wasm, but a simple fake networking is available so tests of other packages that require basic TCP sockets can pass. The tests of the net package itself are mostly disabled. Updates golang#18892 Change-Id: Id287200c39f0a3e23d20ef17260ca15ccdcca032 Reviewed-on: https://go-review.googlesource.com/109995 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
1 parent 0680c03 commit ef9217e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+561
-59
lines changed

src/internal/poll/hook_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
5+
// +build darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris
66

77
package poll
88

src/net/conn_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// This file implements API tests across platforms and will never have a build
66
// tag.
77

8+
// +build !js
9+
810
package net
911

1012
import (

src/net/dial_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
// +build !js
6+
57
package net
68

79
import (

src/net/dnsname_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
// +build !js
6+
57
package net
68

79
import (

src/net/error_posix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
5+
// +build darwin dragonfly freebsd js,wasm linux nacl netbsd openbsd solaris windows
66

77
package net
88

src/net/error_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
// +build !js
6+
57
package net
68

79
import (

src/net/error_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
5+
// +build darwin dragonfly freebsd js linux netbsd openbsd solaris
66

77
package net
88

src/net/external_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
// +build !js
6+
57
package net
68

79
import (

src/net/fd_plan9.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"io"
1010
"os"
1111
"syscall"
12+
"time"
1213
)
1314

1415
// Network file descriptor.
@@ -172,3 +173,15 @@ func setReadBuffer(fd *netFD, bytes int) error {
172173
func setWriteBuffer(fd *netFD, bytes int) error {
173174
return syscall.EPLAN9
174175
}
176+
177+
func (fd *netFD) SetDeadline(t time.Time) error {
178+
return fd.pfd.SetDeadline(t)
179+
}
180+
181+
func (fd *netFD) SetReadDeadline(t time.Time) error {
182+
return fd.pfd.SetReadDeadline(t)
183+
}
184+
185+
func (fd *netFD) SetWriteDeadline(t time.Time) error {
186+
return fd.pfd.SetWriteDeadline(t)
187+
}

src/net/fd_unix.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"runtime"
1414
"sync/atomic"
1515
"syscall"
16+
"time"
1617
)
1718

1819
// Network file descriptor.
@@ -298,3 +299,15 @@ func (fd *netFD) dup() (f *os.File, err error) {
298299

299300
return os.NewFile(uintptr(ns), fd.name()), nil
300301
}
302+
303+
func (fd *netFD) SetDeadline(t time.Time) error {
304+
return fd.pfd.SetDeadline(t)
305+
}
306+
307+
func (fd *netFD) SetReadDeadline(t time.Time) error {
308+
return fd.pfd.SetReadDeadline(t)
309+
}
310+
311+
func (fd *netFD) SetWriteDeadline(t time.Time) error {
312+
return fd.pfd.SetWriteDeadline(t)
313+
}

0 commit comments

Comments
 (0)
X Tutup