This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package cloudfunctions | |
| import ( | |
| "context" | |
| "fmt" | |
| "google.golang.org/api/compute/v1" | |
| "log" | |
| "net/http" | |
| "os" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <sys/types.h> | |
| #include <sys/socket.h> | |
| int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <sys/types.h> /* See NOTES */ | |
| #include <sys/socket.h> | |
| int listen(int sockfd, int backlog); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <sys/types.h> /* See NOTES */ | |
| #include <sys/socket.h> | |
| int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This unimplemnted function is found in the syscall/syscall_linx_386.go file and is referenced by the socket function below. | |
| // It is implemented in the syscall/asm_linux_s390x.s file | |
| func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err Errno) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Unix implementation of bind() system call | |
| int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Unix implementation of socket() system call | |
| int socket(int domain, int type, int protocol); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type conn struct { | |
| fd *netFD | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Close closes the connection. | |
| func (c *conn) Close() error { | |
| if !c.ok() { | |
| return syscall.EINVAL | |
| } | |
| err := c.fd.Close() | |
| if err != nil { | |
| err = &OpError{ | |
| Op: "close", | |
| Net: c.fd.net, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Write implements the Conn Write method. | |
| func (c *conn) Write(b []byte) (int, error) { | |
| if !c.ok() { | |
| return 0, syscall.EINVAL | |
| } | |
| n, err := c.fd.Write(b) | |
| if err != nil { | |
| err = &OpError{ | |
| Op: "write", | |
| Net: c.fd.net, |