Dear all,
What does the function
(_mlock)
do? I don't call the function manually. I found that many functions
(new, _mbschr,_mbscmp,etc)
will use it. I don't know why my program gives the error (runn time error).
I'm going to create an FTP where a client will open a file and read a date and send data toward to the server. The server opens a file and writes that data to the file but when the server goes to open the file it will get a run time error.
void reciveMsg(unsigned int av_sock);
void reciveFile(unsigned int av_sock);
void reciveMsg(unsigned int av_sock)
{
int lv_ret;
char *lp_buff = NULL;
while(1)
{
lp_buff = (char *)malloc(sizeof(513));
memset(lp_buff,0,512);
lv_ret = recv(av_sock,lp_buff,512,0);
printf("\n%s",lp_buff);
delete(lp_buff);
if(lv_ret == -1)
{
closesocket(av_sock);
FD_CLR(av_sock, &master);
printf("\nSocket closed");
return;
}
}
}
void reciveFile(unsigned int av_sock)
{
FILE *fp = NULL;
int lv_ret;
char *lp_buff = NULL;
char lv_bufer[512] = {""}; "//added for color correction
int lv_handle = -1;
lv_handle = _open("D:\\xyz\\test.txt", _O_RDWR);
if(lv_handle == -1)
{
printf("\nError In Opening File");
return;
}
while(1)
{
lp_buff = (char *)malloc(sizeof(1025));
memset(lp_buff,0,1024);
lv_ret = recv(av_sock,lp_buff,1024,0);
lv_ret = _write(lv_handle,lp_buff,sizeof(lp_buff));
if(lv_ret != sizeof(lp_buff))
{
printf("\nTotal Bytes Write [%ld] ",lv_ret);
return;
}
printf("\nWriting In File Please Wait");
}
_close(lv_handle);
}
[Added a double-quote to color-correct the code]