making my own irc client 
Author Message
 making my own irc client

Hey everyone.
I'm working on the Get part of my IRC client. I have mIRC send me a
file and i'm able to make a connection just fine. The trouble i'm
having is when I'm already connected. The DCC spec says recipient
should acknowledge each packet by transmitting the total number of
bytes received as an unsigned, 4 byte
integer in network byte orde. Ok i'm doing this and after i send the
bytes i keep getting transfer incomplete and it goes straight to 100%
when I only recieved 1 packet. This is the code:

::EnterCriticalSection(&gstThreadCritSec);
//This gets the type of event that happened for the socket. The only
events it will recv is FD_CLOSE and FD_READ
if(SOCKET_ERROR == ::WSAEnumNetworkEvents(pstLocalThreadInfo->stSocket[dwEventType],
pstLocalThreadInfo->evSocketEvent[dwEventType], &stNetworkEvents))
{
return ::WSAGetLastError();

Quote:
}

if(stNetworkEvents.lNetworkEvents & FD_READ)
{
DWORD dwTotalRecv = 0 ;
LPSTR szTotalBuffer = NULL;
HANDLE hRecvHandle = NULL;

printf("Entered FD_READ\n");

if(stNetworkEvents.iErrorCode[FD_READ_BIT] != 0)
{
dwError = ::GetLastError();

Quote:
}

//this allocates a buffer
AllocDealloc((PVOID *)&szTotalBuffer, 500000, ALLOC_MEM, &hRecvHandle)
do
{
//this calls WSARecvBuffer.
dwError = RecvBuffer((LPSTR)(szTotalBuffer + dwTotalRecv),
&dwAmountRead, pstLocalThreadInfo->stSocket[dwEventType]);
//dwTotalRecv adds up total bytes gathered during this loop.
dwAmountRead = 0 if no bytes are read and if an error happened
//which i'm wanting a error of 10035 which is an error saying this
call will block
dwTotalRecv += dwAmountRead;

Quote:
}while(dwError == 0);

printf("strlen of szTotal = %d, dwTotalRecv = %d\n",
strlen(szTotalBuffer, dwTotalRecv);

::EnterCriticalSection(&gstDCCGetCritSec);
//This gets the correct thread information like all the sockets &
events used for this thread.
PSTDCCINFO pstTempDccInfo =
GetCorrectDCCStruct(pstLocalThreadInfo->dwThreadID, dwEventType);
//i64TotalRecv is the total amount of bytes rathered in all calls to
RecvBuffer.
pstTempDccInfo->i64TotalRecv += dwTotalRecv;

//This send the correct socket, the total amout of bytes gathered in
all calls and I convert it to network byte order and the size
// which is a size of a unsigned int as the specs call for

printf("Amount of pstTempDccInfo->i64TotalRecv: %d\n",
(UINT)pstTempDccInfo->i64TotalRecv);
//Right the call to sendl is when i get Transfter incomplete
send(pstLocalThreadInfo->stSocket[dwEventType], (char
*)(UINT)htonl((UINT)pstTempDccInfo->i64TotalRecv), sizeof(UINT), 0);

::LeaveCriticalSection(&gstThreadCritSec);

//this deallocates a buffer
AllocDealloc((PVOID *)&szTotalBuffer, 500000, DEALLOC_MEM,
&hRecvHandle)

dwAmountRead = 0;
dwAmountWritten = 0;
dwTotalRecv = 0;
printf("Leaving FD_READ\n");

Quote:
}

Now when I send a file, which the file is 140kb and i'm sending it at
512 packets(which i've done larger also and does the same thing). This
is the result of my calls to:

In FD_READ
strlen 512 dwTotalRecv 512
Amount of pstTempDccInfo->i64TotalRecv 512

Leaving Read
In FD_CLOSE

Like I said, once i leave call send mIRC closes the socket(i have
printf in the FD_CLOSE event too) and puts transfer incomplete. Now,
does anyone know what I could be doing wrong here? Thanks for your
help
Micheal



Thu, 16 Sep 2004 03:18:35 GMT  
 making my own irc client
Quote:

> I'm working on the Get part of my IRC client. I have mIRC send me a
> file and i'm able to make a connection just fine. The trouble i'm
> having is when I'm already connected. The DCC spec says recipient
> should acknowledge each packet by transmitting the total number of
> bytes received as an unsigned, 4 byte
> integer in network byte orde. Ok i'm doing this and after i send the
> bytes i keep getting transfer incomplete and it goes straight to 100%
> when I only recieved 1 packet. This is the code:

> ::EnterCriticalSection(&gstThreadCritSec);
> //This gets the type of event that happened for the socket. The only
> events it will recv is FD_CLOSE and FD_READ
> if(SOCKET_ERROR == ::WSAEnumNetworkEvents(pstLocalThreadInfo->stSocket[dwEventType],
> pstLocalThreadInfo->evSocketEvent[dwEventType], &stNetworkEvents))
> {
> return ::WSAGetLastError();
> }

.... and so on ....

A quick scan of N869 failed to show any mention of DCC,
EnterCriticalSection, ::, SOCKET_ERROR, and many other things in
your post.

Translation: you are in the wrong language, wrong newsgroup, etc.
and far far off-topic.  You don't want c.l.c++ either.  You
probably want something to do with your OS, and when you find it
please read their FAQ before posting.

  http://www.faqs.org/faqs might be of some help.

--

   Available for consulting/temporary embedded and systems.
   (Remove "XXXX" from reply address. yahoo works unmodified)



Thu, 16 Sep 2004 04:34:12 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Making a view own it's own DC in MFC

2. Looking for samples how to write an IRC client in C#

3. .NET IRC Client and Control

4. IRC-Client

5. HELP: Programming an IRC Client for X Window

6. irc chat client's with turbo c

7. IRC server/client C++

8. identd - irc client?

9. function scope when making your own libraries

10. problem making my own library

11. Advice on making your own header file

12. Advise on making own header files

 

 
Powered by phpBB® Forum Software