gnopaste
Userdata
Name
Anonymous
Scriptlanguage
C++
Tabwidth
4
Date
11/05/2009 08:11:09 pm
IP
85.177.202.204
Description
The user was too lazy to give a description
Code (
Hide rownumbers
)
bool
HonProto::connect()
{
NETLIBOPENCONNECTION ncon = { 0 };
ncon.cbSize =
sizeof
(ncon);
ncon.szHost = "127.0.0.1";
//account.chatUrl.c_str();
ncon.wPort = HON_CHAT_PORT;
m_con = (HANDLE) CallService( MS_NETLIB_OPENCONNECTION, (WPARAM) m_hNetlib, (LPARAM) & ncon);
if
(!m_con)
{
// error TODO: talk to the user
return
false
;
}
m_pcon = (HANDLE) CallService(MS_NETLIB_CREATEPACKETRECVER, (WPARAM) m_con, 1024*4);
if
(m_pcon == NULL) {
// Connection Error TODO: Hint!
return
false
;
}
// start receiving messages from host
honFork( &HonProto::ThreadProc, NULL );
Sleep( 100 );
return
m_con != NULL;
}
void
__cdecl HonProto::ThreadProc(
void
* )
{
doReceive();
}
void
HonProto::doReceive()
{
char
chBuf[1024*4+1];
int
cbInBuf = 0;
int
iBufLen = 0;
if
(NLSend("HELP\n", 7) == SOCKET_ERROR)
OutputDebugString(_T("FEJLER"));
NLSend("HELP2323\n", 11);
while
( m_con && m_pcon )
{
NETLIBPACKETRECVER nlpr = { 0 };
nlpr.cbSize =
sizeof
(NETLIBPACKETRECVER);
nlpr.dwTimeout = INFINITE;
nlpr.bufferSize = 1024*4;
iBufLen = (
int
) CallService(MS_NETLIB_GETMOREPACKETS, (WPARAM) m_pcon, (LPARAM) &nlpr);
if
(iBufLen == 0)
break
;
parsePacket(nlpr.buffer, iBufLen);
// what about the ACKS that don't contain data?
}
if
( m_con ) {
Netlib_CloseHandle(m_con);
m_con = NULL;
}
}
submitter »
gnopaster
|
imprint
« imprint
»
Terms of use
«
»
digital bit dot ch - t4c's new home
«