X
xingkong97
Unregistered / Unconfirmed
GUEST, unregistred user!
我写了一个组播程序,可是我想把它做成组件,但是我写的组播程序有这样的数据接收方式:
const
WM_SOCK = WM_USER + 1;
public
procedure ReadData(var Message: TMessage); message WM_SOCK;//读书据过程
。。。
在Form中可以这样写:
WSAAsyncSelect(s, Form1.Handle , WM_SOCK, FD_READ);//s是组播Socket
procedure TForm1.ReadData(var Message: TMessage);
var
buffer: Array [1..4096] of char;
len: integer;
flen: integer;
Event: word;
value: string;
begin
flen:=sizeof(FSockAddrIn);
Event := WSAGetSelectEvent(Message.LParam);
if Event = FD_READ then
begin
len := recvfrom(s, buffer, sizeof(buffer), 0, FSockAddrIn, flen);
value := copy(buffer, 1, len);
Memo1.Lines.add(value)
end;
end;
但是在类中,怎么样去写呢?因为已经没有Form了,那么
WSAAsyncSelect(s, ??, WM_SOCK, FD_READ);该怎么写呢?
const
WM_SOCK = WM_USER + 1;
public
procedure ReadData(var Message: TMessage); message WM_SOCK;//读书据过程
。。。
在Form中可以这样写:
WSAAsyncSelect(s, Form1.Handle , WM_SOCK, FD_READ);//s是组播Socket
procedure TForm1.ReadData(var Message: TMessage);
var
buffer: Array [1..4096] of char;
len: integer;
flen: integer;
Event: word;
value: string;
begin
flen:=sizeof(FSockAddrIn);
Event := WSAGetSelectEvent(Message.LParam);
if Event = FD_READ then
begin
len := recvfrom(s, buffer, sizeof(buffer), 0, FSockAddrIn, flen);
value := copy(buffer, 1, len);
Memo1.Lines.add(value)
end;
end;
但是在类中,怎么样去写呢?因为已经没有Form了,那么
WSAAsyncSelect(s, ??, WM_SOCK, FD_READ);该怎么写呢?