Contrast "socket API" and "WSASocket API"
-
Windows 7, Visual Studio 2012, C++ The Microsoft Web page discussing "
Quote:
Socket overlapped I/O versus blocking/nonblocking mode
found here: http://support.microsoft.com/kb/181611[^] states:
Quote:
To create a socket with the overlapped I/O attribute, you can either use the socket API or the WSASocket API with the WSA_FLAG_OVERLAPPED flag set.
(I added the bolds in the above quote.) What is the difference between socketAPI and WSASocket API? Please show a code fragment that creates a socket with socket API and another that creates it with WSASocket API.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
Windows 7, Visual Studio 2012, C++ The Microsoft Web page discussing "
Quote:
Socket overlapped I/O versus blocking/nonblocking mode
found here: http://support.microsoft.com/kb/181611[^] states:
Quote:
To create a socket with the overlapped I/O attribute, you can either use the socket API or the WSASocket API with the WSA_FLAG_OVERLAPPED flag set.
(I added the bolds in the above quote.) What is the difference between socketAPI and WSASocket API? Please show a code fragment that creates a socket with socket API and another that creates it with WSASocket API.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
Those are the names of the functions:
SOCKET WSAAPI socket(
_In_ int af,
_In_ int type,
_In_ int protocol
);SOCKET WSASocket(
_In_ int af,
_In_ int type,
_In_ int protocol,
_In_ LPWSAPROTOCOL_INFO lpProtocolInfo,
_In_ GROUP g,
_In_ DWORD dwFlags
);The main difference is that
socket
is a function in the C runtime, andWSASocket
is a Windows API.The difficult we do right away... ...the impossible takes slightly longer.
-
Windows 7, Visual Studio 2012, C++ The Microsoft Web page discussing "
Quote:
Socket overlapped I/O versus blocking/nonblocking mode
found here: http://support.microsoft.com/kb/181611[^] states:
Quote:
To create a socket with the overlapped I/O attribute, you can either use the socket API or the WSASocket API with the WSA_FLAG_OVERLAPPED flag set.
(I added the bolds in the above quote.) What is the difference between socketAPI and WSASocket API? Please show a code fragment that creates a socket with socket API and another that creates it with WSASocket API.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
Is there a difference in speed? Edit: My email shows another response that says
Quote:
The main difference is that socket is a function in the C runtime, and WSASocket is a Windows API.
That response does not show up when I log in here. So can I presume that the WSAxxx versions are faster since they bypass the C runtime, which are, presumably, wrappers that then call the API internally?
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
Is there a difference in speed? Edit: My email shows another response that says
Quote:
The main difference is that socket is a function in the C runtime, and WSASocket is a Windows API.
That response does not show up when I log in here. So can I presume that the WSAxxx versions are faster since they bypass the C runtime, which are, presumably, wrappers that then call the API internally?
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
bkelly13 wrote:
can I presume that the WSAxxx versions are faster since they bypass the C runtime
No, you cannot presume anything. It is quite possible (but I don't know) that WSA is built on top of sockets rather than being a complete re-implementation.
-
Is there a difference in speed? Edit: My email shows another response that says
Quote:
The main difference is that socket is a function in the C runtime, and WSASocket is a Windows API.
That response does not show up when I log in here. So can I presume that the WSAxxx versions are faster since they bypass the C runtime, which are, presumably, wrappers that then call the API internally?
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
That response was from me. I deleted it because it was wrong. The
socket
function is not in the C runtime. I'm sorry to have misled you.The difficult we do right away... ...the impossible takes slightly longer.
-
Windows 7, Visual Studio 2012, C++ The Microsoft Web page discussing "
Quote:
Socket overlapped I/O versus blocking/nonblocking mode
found here: http://support.microsoft.com/kb/181611[^] states:
Quote:
To create a socket with the overlapped I/O attribute, you can either use the socket API or the WSASocket API with the WSA_FLAG_OVERLAPPED flag set.
(I added the bolds in the above quote.) What is the difference between socketAPI and WSASocket API? Please show a code fragment that creates a socket with socket API and another that creates it with WSASocket API.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
Hi bkelly13 ! The "WSASocket API" are Microsoft-specific new functions for handling sockets in Windows. If your code is to run on Windows machines only go with this new API since it provides more flexibility and some functionality benefits when working with types of sockets other than blocking. Here are some qoutes from the Remarks paragraph in the MSDN regarding
WSARecv
:Quote:
The WSARecv function provides some additional features compared with the standard recv function in three important areas: •It can be used in conjunction with overlapped sockets to perform overlapped recv operations. •It allows multiple receive buffers to be specified making it applicable to the scatter/gather type of I/O. •The lpFlags parameter is used both on input and returned on output, allowing applications to sense the output state of the MSG_PARTIAL flag bit. However, the MSG_PARTIAL flag bit is not supported by all protocols.
Same goes for
WSASend
:Quote:
The WSASend function provides functionality over and above the standard send function in two important areas: •It can be used in conjunction with overlapped sockets to perform overlapped send operations. •It allows multiple send buffers to be specified making it applicable to the scatter/gather type of I/O.
You can also find code examples for working with these API in there. I have created and worked with sockets using this API (Blocking mode and event-based Overlapped mode) and overall it seems to work fine. If relevant, I can send you the code. :cool: Bye, Amit C.
-
Hi bkelly13 ! The "WSASocket API" are Microsoft-specific new functions for handling sockets in Windows. If your code is to run on Windows machines only go with this new API since it provides more flexibility and some functionality benefits when working with types of sockets other than blocking. Here are some qoutes from the Remarks paragraph in the MSDN regarding
WSARecv
:Quote:
The WSARecv function provides some additional features compared with the standard recv function in three important areas: •It can be used in conjunction with overlapped sockets to perform overlapped recv operations. •It allows multiple receive buffers to be specified making it applicable to the scatter/gather type of I/O. •The lpFlags parameter is used both on input and returned on output, allowing applications to sense the output state of the MSG_PARTIAL flag bit. However, the MSG_PARTIAL flag bit is not supported by all protocols.
Same goes for
WSASend
:Quote:
The WSASend function provides functionality over and above the standard send function in two important areas: •It can be used in conjunction with overlapped sockets to perform overlapped send operations. •It allows multiple send buffers to be specified making it applicable to the scatter/gather type of I/O.
You can also find code examples for working with these API in there. I have created and worked with sockets using this API (Blocking mode and event-based Overlapped mode) and overall it seems to work fine. If relevant, I can send you the code. :cool: Bye, Amit C.
I understand and am going with the WSA series. I am putting significant effort into this project. If you have code you don't mind sending, I will look at it. I am declaring my code as open source and will post it. Please send to user name "online" with that symbol followed by my domain bkelly then further followed by dot "ws", yes, its just that simple. Thank you for the time you spent on your reply.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com