2016-11-25 10:18:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* machinarium.
|
|
|
|
*
|
|
|
|
* Cooperative multitasking engine.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <machinarium_private.h>
|
|
|
|
#include <machinarium.h>
|
|
|
|
|
|
|
|
MM_API int
|
2016-11-29 12:21:38 +00:00
|
|
|
mm_bind(mm_io_t iop, char *addr, int port)
|
2016-11-25 10:18:13 +00:00
|
|
|
{
|
|
|
|
mmio *io = iop;
|
|
|
|
struct sockaddr_in saddr;
|
|
|
|
int rc;
|
|
|
|
rc = uv_ip4_addr(addr, port, &saddr);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
rc = uv_tcp_bind(&io->handle, (struct sockaddr*)&saddr, 0);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
return 0;
|
|
|
|
}
|