Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 396:c262f421a44c legacy-trunk
Added allowbroadcast()
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sun, 20 Oct 1991 20:22:28 +0000 |
| parents | 70a18a6689d4 |
| children | a5f0b8390c87 |
line wrap: on
line diff
--- a/Modules/socketmodule.c Sun Oct 20 20:21:15 1991 +0000 +++ b/Modules/socketmodule.c Sun Oct 20 20:22:28 1991 +0000 @@ -33,7 +33,7 @@ - no asynchronous I/O (but read polling: avail) - no read/write operations (use send/recv or makefile instead) - no flags on sendto/recvfrom operations -- no setsockopt() call +- no general setsockopt() call (but see s.allowbroadcast()) Interface: @@ -53,6 +53,7 @@ - s.accept() --> new socket object, sockaddr - s.avail() --> boolean +- s.allowbroadcast(boolean) --> None - s.bind(sockaddr) --> None - s.connect(sockaddr) --> None - s.listen(n) --> None @@ -341,6 +342,26 @@ } +/* s.allowbroadcast() method */ + +static object * +sock_allowbroadcast(s, args) + sockobject *s; + object *args; +{ + int flag; + int res; + if (!getintarg(args, &flag)) + return NULL; + res = setsockopt(s->sock_fd, SOL_SOCKET, SO_BROADCAST, + &flag, sizeof flag); + if (res < 0) + return socket_error(); + INCREF(None); + return None; +} + + /* s.avail() method */ static object * @@ -582,6 +603,7 @@ static struct methodlist sock_methods[] = { {"accept", sock_accept}, {"avail", sock_avail}, + {"allowbroadcast", sock_allowbroadcast}, {"bind", sock_bind}, {"close", sock_close}, {"connect", sock_connect},
