added mio_svc_htts_getsockaddr(), mio_dev_sck_getsockaddr(), mio_dev_sck_getpeeraddr()
This commit is contained in:
parent
a7ae566736
commit
93a7073e48
@ -360,7 +360,7 @@ mio_svc_htts_t* mio_svc_htts_start (mio_t* mio, mio_dev_sck_bind_t* sck_bind, mi
|
|||||||
htts->lsck = mio_dev_sck_make(mio, MIO_SIZEOF(*cli), &info.m);
|
htts->lsck = mio_dev_sck_make(mio, MIO_SIZEOF(*cli), &info.m);
|
||||||
if (!htts->lsck) goto oops;
|
if (!htts->lsck) goto oops;
|
||||||
|
|
||||||
/* the name 'cli' for the listening socket is awkard.
|
/* the name 'cli' for the listening socket is awkward.
|
||||||
* the listening socket will use the htts and sck fields for tracking only.
|
* the listening socket will use the htts and sck fields for tracking only.
|
||||||
* each accepted client socket gets the extension size for this size as well.
|
* each accepted client socket gets the extension size for this size as well.
|
||||||
* most of other fields are used for client management */
|
* most of other fields are used for client management */
|
||||||
@ -373,7 +373,7 @@ mio_svc_htts_t* mio_svc_htts_start (mio_t* mio, mio_dev_sck_bind_t* sck_bind, mi
|
|||||||
if (mio_dev_sck_bind(htts->lsck, sck_bind) <= -1) goto oops;
|
if (mio_dev_sck_bind(htts->lsck, sck_bind) <= -1) goto oops;
|
||||||
|
|
||||||
MIO_MEMSET (&info, 0, MIO_SIZEOF(info));
|
MIO_MEMSET (&info, 0, MIO_SIZEOF(info));
|
||||||
info.l.backlogs = 4096;
|
info.l.backlogs = 4096; /* TODO: use configuration? */
|
||||||
MIO_INIT_NTIME (&info.l.accept_tmout, 5, 1); /* usedd for ssl accept */
|
MIO_INIT_NTIME (&info.l.accept_tmout, 5, 1); /* usedd for ssl accept */
|
||||||
if (mio_dev_sck_listen(htts->lsck, &info.l) <= -1) goto oops;
|
if (mio_dev_sck_listen(htts->lsck, &info.l) <= -1) goto oops;
|
||||||
}
|
}
|
||||||
@ -454,6 +454,12 @@ int mio_svc_htts_setservernamewithbcstr (mio_svc_htts_t* htts, const mio_bch_t*
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mio_svc_htts_getsockaddr (mio_svc_htts_t* htts, mio_skad_t* skad)
|
||||||
|
{
|
||||||
|
/* return the socket address of the listening socket. */
|
||||||
|
return mio_dev_sck_getsockaddr(htts->lsck, skad);
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
|
|
||||||
mio_svc_htts_rsrc_t* mio_svc_htts_rsrc_make (mio_svc_htts_t* htts, mio_oow_t rsrc_size, mio_svc_htts_rsrc_on_kill_t on_kill)
|
mio_svc_htts_rsrc_t* mio_svc_htts_rsrc_make (mio_svc_htts_t* htts, mio_oow_t rsrc_size, mio_svc_htts_rsrc_on_kill_t on_kill)
|
||||||
|
@ -275,6 +275,11 @@ MIO_EXPORT int mio_svc_htts_setservernamewithbcstr (
|
|||||||
const mio_bch_t* server_name
|
const mio_bch_t* server_name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
MIO_EXPORT int mio_svc_htts_getsockaddr (
|
||||||
|
mio_svc_htts_t* htts,
|
||||||
|
mio_skad_t* skad
|
||||||
|
);
|
||||||
|
|
||||||
MIO_EXPORT int mio_svc_htts_docgi (
|
MIO_EXPORT int mio_svc_htts_docgi (
|
||||||
mio_svc_htts_t* htts,
|
mio_svc_htts_t* htts,
|
||||||
mio_dev_sck_t* csck,
|
mio_dev_sck_t* csck,
|
||||||
|
@ -576,6 +576,17 @@ MIO_EXPORT int mio_dev_sck_getsockopt (
|
|||||||
mio_scklen_t* optlen
|
mio_scklen_t* optlen
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
MIO_EXPORT int mio_dev_sck_getsockaddr (
|
||||||
|
mio_dev_sck_t* dev,
|
||||||
|
mio_skad_t* skad
|
||||||
|
);
|
||||||
|
|
||||||
|
MIO_EXPORT int mio_dev_sck_getpeeraddr (
|
||||||
|
mio_dev_sck_t* dev,
|
||||||
|
mio_skad_t* skad
|
||||||
|
);
|
||||||
|
|
||||||
MIO_EXPORT int mio_dev_sck_shutdown (
|
MIO_EXPORT int mio_dev_sck_shutdown (
|
||||||
mio_dev_sck_t* dev,
|
mio_dev_sck_t* dev,
|
||||||
int how /* bitwise-ORed of mio_dev_sck_shutdown_how_t enumerators */
|
int how /* bitwise-ORed of mio_dev_sck_shutdown_how_t enumerators */
|
||||||
|
@ -1538,7 +1538,7 @@ static int make_accepted_client_connection (mio_dev_sck_t* rdev, mio_syshnd_t cl
|
|||||||
{
|
{
|
||||||
/* this is a special optional callback. If you don't want a client socket device
|
/* this is a special optional callback. If you don't want a client socket device
|
||||||
* to be created upon accept, you may implement the on_raw_accept() handler.
|
* to be created upon accept, you may implement the on_raw_accept() handler.
|
||||||
* the socket handle is delated to the callback. */
|
* the socket handle is delegated to the callback. */
|
||||||
rdev->on_raw_accept (rdev, clisck, remoteaddr);
|
rdev->on_raw_accept (rdev, clisck, remoteaddr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2163,6 +2163,28 @@ int mio_dev_sck_getsockopt (mio_dev_sck_t* dev, int level, int optname, void* op
|
|||||||
return getsockopt(dev->hnd, level, optname, optval, optlen);
|
return getsockopt(dev->hnd, level, optname, optval, optlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int mio_dev_sck_getsockaddr (mio_dev_sck_t* dev, mio_skad_t* skad)
|
||||||
|
{
|
||||||
|
mio_scklen_t addrlen = MIO_SIZEOF(*skad);
|
||||||
|
if (getsockname(dev->hnd, (struct sockaddr*)skad, &addrlen) <= -1)
|
||||||
|
{
|
||||||
|
mio_seterrwithsyserr (dev->mio, 0, errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mio_dev_sck_getpeeraddr (mio_dev_sck_t* dev, mio_skad_t* skad)
|
||||||
|
{
|
||||||
|
mio_scklen_t addrlen = MIO_SIZEOF(*skad);
|
||||||
|
if (getpeername(dev->hnd, (struct sockaddr*)skad, &addrlen) <= -1)
|
||||||
|
{
|
||||||
|
mio_seterrwithsyserr (dev->mio, 0, errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int mio_dev_sck_shutdown (mio_dev_sck_t* dev, int how)
|
int mio_dev_sck_shutdown (mio_dev_sck_t* dev, int how)
|
||||||
{
|
{
|
||||||
switch (how & (MIO_DEV_SCK_SHUTDOWN_READ | MIO_DEV_SCK_SHUTDOWN_WRITE))
|
switch (how & (MIO_DEV_SCK_SHUTDOWN_READ | MIO_DEV_SCK_SHUTDOWN_WRITE))
|
||||||
@ -2184,7 +2206,13 @@ int mio_dev_sck_shutdown (mio_dev_sck_t* dev, int how)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return shutdown(dev->hnd, how);
|
if (shutdown(dev->hnd, how) <= -1)
|
||||||
|
{
|
||||||
|
mio_seterrwithsyserr (dev->mio, 0, errno);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mio_dev_sck_sendfileok (mio_dev_sck_t* dev)
|
int mio_dev_sck_sendfileok (mio_dev_sck_t* dev)
|
||||||
|
Loading…
Reference in New Issue
Block a user