Board index » delphi » Winsock for TPW

Winsock for TPW

Hi, I am currently *trying* to make a IRC client in TPW but I have
come across a small problem which I cannot resolve,
the recv function WAITS for data to be received, I want it to check
what data there is, and if there is some recieve it, my current
procedure is as follows :-

procedure RecvTxt(ABuff : PChar);
var
  rc,i : integer;
begin
  rc := recv(IRCsocket, ABuff, 1024, 0);
  if rc = SOCKET_ERROR then begin
    Error('Recv');
  end
  else if rc = 0 then begin
    ABuff := '';
  end;
end;

and the recv functions looks like this,

 function recv (s : tSOCKET; buf : PChar; len, flags : integer) :
integer;

function recv;              external    'WINSOCK' index 16;

I want information coming from the IRC server to be constantly updated
on my client, but it will not work, it will wait for data to be
recived thus halting anything else i want to do, such as send data.

Anyone ?

Gary

 

Re:Winsock for TPW


Quote
Gary wrote:

> Hi, I am currently *trying* to make a IRC client in TPW but I have
> come across a small problem which I cannot resolve,
> the recv function WAITS for data to be received, I want it to check
> what data there is, and if there is some recieve it, my current
> procedure is as follows :-

> procedure RecvTxt(ABuff : PChar);
> var
>   rc,i : integer;
> begin
>   rc := recv(IRCsocket, ABuff, 1024, 0);
>   if rc = SOCKET_ERROR then begin
>     Error('Recv');
>   end
>   else if rc = 0 then begin
>     ABuff := '';
>   end;
> end;

> and the recv functions looks like this,

>  function recv (s : tSOCKET; buf : PChar; len, flags : integer) :
> integer;

> function recv;              external    'WINSOCK' index 16;

> I want information coming from the IRC server to be constantly updated
> on my client, but it will not work, it will wait for data to be
> recived thus halting anything else i want to do, such as send data.

> Anyone ?

> Gary

This may be done with the Asynchronous library routines - namely
WSAAsyncSelect() will let you register interest in an event (such as
data waiting) which will send your window a message. Check out the
Winsock 1.1 spec at:

        ftp://ftp.stardust.com/pub/winsock/version1/docs/spec/

you may retrieve the spec in several formats. the BP unit may also be
downloaded here.

Les

Other Threads