 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Thu May 24, 2007 11:28 am Post subject: [Help] Using non-blocking sockets in C# or in delphi |
|
|
Hi,
I'm trying to make a little online program, not something big, just a little program that allows you to send and recive text/byte arrays. I made a little program like this, but using a blocking socket, in C#, but there is a much better way with the non-blocking sockets. I read about it in MSDN, but they don't explain it enough.. I took a source code that I found somewhere, but when I try to modify it a little it gives me errors, so I need a better base on non-blocking sockets. I understand the main idea of it, using the delegate AsyncCallback and the BeginRecive and EndRecive functions, but it's a little complicate to learn only from 1 source code and from MSDN..
Does any1 knows something about it?
|
|
| Back to top |
|
 |
Robotex Master Cheater
Reputation: 0
Joined: 05 Sep 2006 Posts: 378 Location: The pizza country!
|
Posted: Thu May 24, 2007 11:50 am Post subject: |
|
|
here's a small example i use for a proxy dll
| Code: | FD_SET Reader;
unsigned long NonBlock=1;
ioctlsocket(ClientSocket, FIONBIO, &NonBlock);
do
{
FD_ZERO(&Reader);
FD_SET(ClientSocket, &Reader);
select(0, &Reader, NULL, NULL, NULL);
if(FD_ISSET(ClientSocket, &Reader))
{
iResult = recv(ClientSocket,buf,DEFAULT_BUFLEN,0);
if(iResult > 0)
{
MessageBoxA(NULL,"My text", buf,MB_OK);
}
else if(iResult == 0)
{
add_log("Client closed the connection");
Close=true;
}
else
{
MessageBoxA(NULL,"ERROR","Error!",MB_OK);
}
}
} while (!Close); |
_________________
ASM/C++ Coder
Project Speranza lead developer |
|
| Back to top |
|
 |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Thu May 24, 2007 9:54 pm Post subject: |
|
|
Well, that looks like C++, I need something for C#.. But ty anyway..
I meant that I want to make a socket that will create events when there is a packet to recive, your example is just in a loop that takes a lot of CPU
|
|
| Back to top |
|
 |
Flyte Peanuts!!!!
Reputation: 6
Joined: 19 Apr 2006 Posts: 1887 Location: Canada
|
Posted: Thu May 24, 2007 9:55 pm Post subject: |
|
|
| assaf84 wrote: | Well, that looks like C++, I need something for C#.. But ty anyway..
I meant that I want to make a socket that will create events when there is a packet to recive, your example is just in a loop that takes a lot of CPU |
You pretty much have to have a loop to recieve packets. From this loop is where you create whatever event you want.
|
|
| Back to top |
|
 |
Uzeil Moderator
Reputation: 6
Joined: 21 Oct 2006 Posts: 2411
|
Posted: Thu May 24, 2007 10:49 pm Post subject: |
|
|
If you're looking for for the socket API in Delphi, I suggest looking through Sockets.pas (not to mention adding it to your uses list.)
The names are a bit different but still obvious. recv->DoRecieve, send->DoSend, etc.
I'm mystified as to why they took recv and send out of the WinAPI derivitive 'Windows.'
_________________
|
|
| Back to top |
|
 |
assaf84 Expert Cheater
Reputation: 0
Joined: 03 Oct 2006 Posts: 238
|
Posted: Fri May 25, 2007 12:36 am Post subject: |
|
|
| Flyte wrote: | | assaf84 wrote: | Well, that looks like C++, I need something for C#.. But ty anyway..
I meant that I want to make a socket that will create events when there is a packet to recive, your example is just in a loop that takes a lot of CPU |
You pretty much have to have a loop to recieve packets. From this loop is where you create whatever event you want. |
yes, but I want to do it on an independent thread, so it won't interrupt the rest of the application. I prefer doing it on C#, so if any1 can give me some examples..
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|