hoi iedereen ,
Ik heb een probleem, ik ben een progje aan het maken om sockets uit te lezen via delphi. Ik heb wel een stukje script gevonden maar dat is in c++ en daar ben ik een n00b in. Dus nu zoek ik iemand die dit om kan zetten naar delphi.
#include "stdafx.h"
#include "afxsock.h"
CWinApp theApp;
using namespace std;
void failure (char *err)
{
AfxMessageBox (err);
exit (-1);
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
failure ("Unable to init MFC!");
// initialize sockets
if (!AfxSocketInit ())
failure ("Unable to init Winsock!");
CSocket in;
if (!in.Create (443))
failure ("Unable to init Socket!");
in.Listen (5);
while (1)
{
// blocks until connection received
CSocket newconn;
BOOL rc = in.Accept (newconn);
if (!rc)
{
printf ("ACCEPT ERROR!\n");
continue;
}
struct tm *newtime;
time_t aclock;
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
// get one byte
char buf;
int num_received = newconn.Receive (&buf, 1);
newconn.Close ();
if (num_received)
{
cout << asctime( newtime );
switch (buf)
{
}
}
}
in.Close ();
return 0;
}
Kan iemand dit omzetten naar delphi of mij uitleggen hoe het werkt??
Mvg Gar
Ik heb een probleem, ik ben een progje aan het maken om sockets uit te lezen via delphi. Ik heb wel een stukje script gevonden maar dat is in c++ en daar ben ik een n00b in. Dus nu zoek ik iemand die dit om kan zetten naar delphi.
#include "stdafx.h"
#include "afxsock.h"
CWinApp theApp;
using namespace std;
void failure (char *err)
{
AfxMessageBox (err);
exit (-1);
}
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
failure ("Unable to init MFC!");
// initialize sockets
if (!AfxSocketInit ())
failure ("Unable to init Winsock!");
CSocket in;
if (!in.Create (443))
failure ("Unable to init Socket!");
in.Listen (5);
while (1)
{
// blocks until connection received
CSocket newconn;
BOOL rc = in.Accept (newconn);
if (!rc)
{
printf ("ACCEPT ERROR!\n");
continue;
}
struct tm *newtime;
time_t aclock;
time( &aclock ); /* Get time in seconds */
newtime = localtime( &aclock ); /* Convert time to struct */
// get one byte
char buf;
int num_received = newconn.Receive (&buf, 1);
newconn.Close ();
if (num_received)
{
cout << asctime( newtime );
switch (buf)
{
}
}
}
in.Close ();
return 0;
}
Kan iemand dit omzetten naar delphi of mij uitleggen hoe het werkt??
Mvg Gar