Click here to Skip to main content
15,877,553 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: How to find unallocated sector in a disk programaticaaly Pin
Randor 31-Oct-09 3:44
professional Randor 31-Oct-09 3:44 
QuestionRunning a process as Administrator in Vista, Windows 2008? Pin
Kushagra Tiwari31-Oct-09 1:05
Kushagra Tiwari31-Oct-09 1:05 
AnswerRe: Running a process as Administrator in Vista, Windows 2008? [modified] Pin
Randor 31-Oct-09 1:50
professional Randor 31-Oct-09 1:50 
GeneralRe: Running a process as Administrator in Vista, Windows 2008? Pin
Kushagra Tiwari31-Oct-09 2:11
Kushagra Tiwari31-Oct-09 2:11 
GeneralRe: Running a process as Administrator in Vista, Windows 2008? Pin
Randor 31-Oct-09 2:18
professional Randor 31-Oct-09 2:18 
GeneralRe: Running a process as Administrator in Vista, Windows 2008? Pin
Kushagra Tiwari31-Oct-09 2:22
Kushagra Tiwari31-Oct-09 2:22 
QuestionRe: Running a process as Administrator in Vista, Windows 2008? Pin
Kushagra Tiwari1-Nov-09 19:51
Kushagra Tiwari1-Nov-09 19:51 
QuestionTrying to send a pdf file using Sockets Pin
WindowsVsLinux30-Oct-09 22:10
WindowsVsLinux30-Oct-09 22:10 
Hi,
I am trying to send a pdf file from server to client using sockets. My code is

server:
FILE *fp;
int i,j,endoffile;
char buf[1024],pathoffile[1024],msg[24];

if((send(TheClient,msg,sizeof(msg),0))!=0)

if((recv(TheClient,pathoffile,sizeof(pathoffile),0))!=0)
printf("\n\tPath is %s",pathoffile);

fp=fopen(pathoffile,"rb");
if(fp==NULL)
{
printf("\n\tFailed to open File");
system("pause");
}

for (i=0, endoffile=0 ; ; )
{
j = fread(buf, 1, sizeof(buf), fp);
if (j < 0)
{
system("pause");
}
if (j == 0)
{
endoffile = 1;
printf("\n\tFile successfully sent");
system("pause");
}
j = send(TheClient, buf, j, 0);
printf("\n\tsending buf to client.Value of send %d",j);
if (j <= 0)
{
printf("\n\tUnable to send");
system("pause");
}
}
}


client:
int i,j;
HANDLE hFile=NULL;
char buf[1024],msg[24],pathoffile[1024];
DWORD dw;

if((recv(sock,msg,sizeof(msg),0))!=0)
printf("\n\t%s",msg);
gets(pathoffile);
if((send(sock,pathoffile,sizeof(pathoffile),0))!=0)
printf("path sent sucessfully");

hFile = CreateFileA(".", GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == NULL || hFile == INVALID_HANDLE_VALUE)
{
hFile = NULL;
}
for (i=0 ; ; )
{
j=recv(sock, buf, sizeof(buf), 0);
printf("\n\treceiving file...plz wait.");
if (j <= 0)
break;
i += j;
WriteFile(hFile, buf, j, &dw, 0);
}
CloseHandle(hFile);

when i run my program .in server window it shows "sending buf to client.Value of send 0".I am unable to that where is the error happaning?
AnswerRe: Trying to send a pdf file using Sockets Pin
Richard MacCutchan31-Oct-09 0:43
mveRichard MacCutchan31-Oct-09 0:43 
Questioncin &gt;&gt; foo; Sometimes it doesn't take... Pin
CaptainSeeSharp30-Oct-09 19:21
CaptainSeeSharp30-Oct-09 19:21 
AnswerRe: cin &gt;&gt; foo; Sometimes it doesn't take... Pin
LunaticFringe30-Oct-09 19:37
LunaticFringe30-Oct-09 19:37 
GeneralRe: cin &gt;&gt; foo; Sometimes it doesn't take... Pin
CaptainSeeSharp30-Oct-09 19:41
CaptainSeeSharp30-Oct-09 19:41 
GeneralRe: cin &gt;&gt; foo; Sometimes it doesn't take... Pin
N a v a n e e t h30-Oct-09 19:46
N a v a n e e t h30-Oct-09 19:46 
GeneralRe: cin &gt;&gt; foo; Sometimes it doesn't take... Pin
CaptainSeeSharp30-Oct-09 19:48
CaptainSeeSharp30-Oct-09 19:48 
GeneralRe: cin &gt;&gt; foo; Sometimes it doesn't take... Pin
LunaticFringe30-Oct-09 19:47
LunaticFringe30-Oct-09 19:47 
GeneralRe: cin &gt;&gt; foo; Sometimes it doesn't take... Pin
CaptainSeeSharp30-Oct-09 19:50
CaptainSeeSharp30-Oct-09 19:50 
GeneralRe: cin &gt;&gt; foo; Sometimes it doesn't take... Pin
LunaticFringe30-Oct-09 19:55
LunaticFringe30-Oct-09 19:55 
GeneralRe: cin &gt;&gt; foo; Sometimes it doesn't take... Pin
CaptainSeeSharp30-Oct-09 20:02
CaptainSeeSharp30-Oct-09 20:02 
GeneralRe: cin &gt;&gt; foo; Sometimes it doesn't take... Pin
LunaticFringe30-Oct-09 20:14
LunaticFringe30-Oct-09 20:14 
GeneralRe: cin &gt;&gt; foo; Sometimes it doesn't take... Pin
Randor 30-Oct-09 22:31
professional Randor 30-Oct-09 22:31 
QuestionLPCSTR and char* issues Pin
MbHimself30-Oct-09 17:34
MbHimself30-Oct-09 17:34 
AnswerRe: LPCSTR and char* issues [modified] Pin
LunaticFringe30-Oct-09 18:46
LunaticFringe30-Oct-09 18:46 
GeneralRe: LPCSTR and char* issues Pin
MbHimself30-Oct-09 19:09
MbHimself30-Oct-09 19:09 
GeneralRe: LPCSTR and char* issues Pin
LunaticFringe30-Oct-09 19:42
LunaticFringe30-Oct-09 19:42 
AnswerRe: LPCSTR and char* issues Pin
«_Superman_»30-Oct-09 19:40
professional«_Superman_»30-Oct-09 19:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.