Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Help] Using non-blocking sockets in C# or in delphi

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu May 24, 2007 11:28 am    Post subject: [Help] Using non-blocking sockets in C# or in delphi Reply with quote

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
View user's profile Send private message
Robotex
Master Cheater
Reputation: 0

Joined: 05 Sep 2006
Posts: 378
Location: The pizza country!

PostPosted: Thu May 24, 2007 11:50 am    Post subject: Reply with quote

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
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Thu May 24, 2007 9:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Thu May 24, 2007 9:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
Uzeil
Moderator
Reputation: 6

Joined: 21 Oct 2006
Posts: 2411

PostPosted: Thu May 24, 2007 10:49 pm    Post subject: Reply with quote

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.'

_________________


Mini Engine v3.0
Mipla v1.0

Reposted old threads out of the MS section.
Back to top
View user's profile Send private message
assaf84
Expert Cheater
Reputation: 0

Joined: 03 Oct 2006
Posts: 238

PostPosted: Fri May 25, 2007 12:36 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites