struct sockaddr_in
socket :: NativeSocketAddrIn :: address
Internet address as then IPV4 numbers-and-dots notationsocket :: NativeSocketAddrIn :: address_broadcast
Setaddress
to INADDR_BROADCAST
socket :: NativeSocketAddrIn :: family=
Address familysocket :: NativeSocketAddrIn :: fill_from_hostent
Setaddress
and family
from hostent
(to use with Sys::gethostbyname
)
socket $ NativeSocketAddrIn :: SELF
Type of this instance, automatically specialized in every classsocket :: NativeSocketAddrIn :: address
Internet address as then IPV4 numbers-and-dots notationsocket :: NativeSocketAddrIn :: address_broadcast
Setaddress
to INADDR_BROADCAST
core :: Pointer :: address_is_null
Is the address behind this Object at NULL?core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
core :: Pointer :: defaultinit
socket :: NativeSocketAddrIn :: family=
Address familysocket :: NativeSocketAddrIn :: fill_from_hostent
Setaddress
and family
from hostent
(to use with Sys::gethostbyname
)
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# Socket address in the Internet namespace, pointer to a `struct sockaddr_in`
extern class NativeSocketAddrIn `{ struct sockaddr_in* `}
# `NULL` pointer
new nul `{ return NULL; `}
# `malloc` a new instance
new `{
struct sockaddr_in *sai = NULL;
sai = malloc(sizeof(struct sockaddr_in));
return sai;
`}
# Set `address` and `family` from `hostent` (to use with `Sys::gethostbyname`)
fun fill_from_hostent(hostent: NativeSocketHostent) `{
self->sin_family = hostent->h_addrtype;
memcpy((char*)&self->sin_addr.s_addr,
(char*)hostent->h_addr,
hostent->h_length);
`}
# Internet address as then IPV4 numbers-and-dots notation
fun address: CString `{ return (char*)inet_ntoa(self->sin_addr); `}
# Set `address` to `INADDR_ANY`
fun address_any `{ self->sin_addr.s_addr = INADDR_ANY; `}
# Set `address` to `INADDR_BROADCAST`
fun address_broadcast `{ self->sin_addr.s_addr = INADDR_BROADCAST; `}
# Address family
fun family: NativeSocketAddressFamilies `{ return self->sin_family; `}
# Address family
fun family=(value: NativeSocketAddressFamilies) `{ self->sin_family = value; `}
# Port
fun port: Int `{ return ntohs(self->sin_port); `}
# Port
fun port=(value: Int) `{ self->sin_port = htons(value); `}
end
lib/socket/socket_c.nit:273,1--314,3