|
MXFlushCom |
C
NetProg Library |
|
#include
"mx.h"
|
|
|
int MXFlushCom (MX* pmx, MXCom* pcom) |
|
Parameters |
Description |
pmx |
the
MX manager |
pcom |
the
connection instance |
This function flushes the
output queue of a connection. Messages in the output queue of a connection are
sent by the MX manager, in a scheduled manner. If an application wants to close
a connection it uses this function to send all messages still pending.
Notice that an application that works in an asynchronous mode uses MXPutMessage
which only puts the message in the output queue. The messages in the output are
sent by MXDispatchEvents
Return
Values :
if error returns < 0 else returns >= 0
|
...
if (STORE)
{
char FileType = 't';
FileCom = MXOpenFile (&mx, "FTP.sto", "w", IOPROTO_STORE, 'D', 63);
if (!FileCom) return 0;
pmessage = MXPutMessage (FileCom,
FTP_SYS, "Command");
MXSetValue (pmessage, "Value", 1, "USER");
MXSetValue (pmessage, "Par", 1, "bartocci");
pmessage = MXPutMessage (FileCom, FTP_SYS, "Command");
MXSetValue (pmessage, "Value", 1, "PASS");
MXSetValue (pmessage, "Par", 1, "pass");
pmessage = MXPutMessage (FileCom, FTP_SYS, "dir");
MXSetValue (pmessage, "Value", 1, "LIST");
MXSetValue (pmessage, "Par", 1, "");
pmessage = MXPutMessage (FileCom, FTP_SYS, "get") ;
MXSetValue(pmessage, "FileName", 1, "t.c") ;
MXSetValue(pmessage, "DestName", 1, "t.c") ;
MXSetValue(pmessage, "FileType", 1, &FileType) ;
MXSetValue(pmessage, "Command", 1, "get") ;
MXFlushCom (&mx, FileCom);
MXCloseCom (&mx, FileCom);
FTPCom = MXOpenTCP (&mx, "194.214.100.8", 21, IPPROTO_FTP, NULL, NULL, TRUE);
if (!FTPCom) return 0;
MXAddComCallBack (&mx, FTPCom, FTP_SYS, "Command", MXONSEND, Command, NULL);
MXAddComCallBack (&mx, FTPCom, FTP_SYS, "Command_Reply", MXONRECV, CommandReply, NULL);
MXAddComCallBack (&mx, FTPCom, FTP_SYS, "dir_reply", MXONRECV, DirReply, NULL);
MXAddComCallBack (&mx, FTPCom, FTP_SYS, "get_reply", MXONRECV, GetReply, NULL);
FileCom = MXOpenFile (&mx, "FTP.sto", "r", IOPROTO_STORE, 'D', 63);
if (!FileCom) return 0;
while (pmessage = MXRecv (&mx, FileCom))
{
MXPutThisMessage (FTPCom, pmessage);
}
MXCloseCom (&mx, FileCom);
}
...
MXDispatchEvents (&mx, 0);
MXEnd (&mx);
return 0;
|
|