News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

TransmitFile

Started by six_L, September 01, 2008, 05:47:27 AM

Previous topic - Next topic

six_L

how uses the TransmitFile to upload multifiles on network?
regards

six_L

#1
The TransmitFile function uses the operating system's cache manager to retrieve the file data, and provide high-performance file data transfer over sockets.
on network which its packet go through the router, it's powerful. but i only can use it on the socket with blocking mode.

Enable or disable nonblocking mode on socket s. lpvInBuffer points at an unsigned long, which is nonzero if nonblocking mode is to be enabled and zero if it is to be disabled. When a socket is created, it operates in blocking mode (that is, nonblocking mode is disabled). This is consistent with BSD sockets.
The WSAAsyncSelect or WSAEventSelect routine automatically sets a socket to nonblocking mode. If WSAAsyncSelect or WSAEventSelect has been issued on a socket, then any attempt to use WSAIoctl to set the socket back to blocking mode will fail with WSAEINVAL. To set the socket back to blocking mode, an application must first disable WSAAsyncSelect by calling WSAAsyncSelect with the lEvent parameter equal to zero, or disable WSAEventSelect by calling WSAEventSelect with the lNetworkEvents parameter equal to zero.
...
invoke WSAAsyncSelect,hSocket,hMain,WM_SOCKET,FD_CONNECT or FD_READ or FD_CLOSE ;nonblocking mode
...
invoke WSAIoctl, hSocket, FIONBIO, addr OptVal, 4d, 0h, 0h, addr BytesRet, 0h, 0h ;change to blocking mode
...

i want to change a socket to blocking mode from nonblocking mode, and back again.
regards

Tedd

I think if you call WSAAsyncSelect(hSock,hwnd,0,0) it sets the socket back to blocking mode (though there may still be some async events waiting to be handled.)

Don't mix the two methods - either use only WSAAsyncSelect, or only WSAIoctl to enable/disable blocking.
No snowflake in an avalanche feels responsible.

six_L

Hello, Tedd
Thanks for your help.

i'm still being failed at enable/disable blocking mode alterability.
i'll post the blocking mode codes about TransmitFile. i'm wild about its high-performance file data transfer over sockets
hope someone to add The TransmitFile function on nonblocking mode socket.

regards

hoverlees

hi six_L
The remarks of ioctlsocket says:

To set the socket back to blocking mode, an application must first disable WSAAsyncSelect by calling WSAAsyncSelect with the lEvent parameter equal to zero, or disable WSAEventSelect by calling WSAEventSelect with the lNetworkEvents parameter equal to zero.


So,as Tedd said,you must first call WSAAsyncSelect(hSock,hwnd,0,0)
and then call WSAIoctl or ioctlsocket function.
Good luck! :wink

six_L

hello,hoverlees
thanks your help.

here is the blocking mode's code for send somefiles to server from a client.

[attachment deleted by admin]
regards

ecube

thanks for the example, keep in mind though transmitefile isn't very ideal for large files because if you get disconnected half way through for instance you have to start all over again.