Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: code conflict I cannot see whats wrong



Permlink Replies: 2 - Last Post: Aug 18, 2016 10:12 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Lex Dean

Posts: 132
Registered: 3/26/07
code conflict I cannot see whats wrong
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2016 3:29 AM
I'm try to make a winsock2 object as most Delphi programmers cannot see past Indy
including multi threading/overlapping advantages, it offers a routine to return once the data is transferred for client and server. This is what I'm trying to implement but I have a code conflict that I do not understand.
I have come to the point where I'm asking Questions is thier a WinSock2 *.Dll error that the dll has extra values in the procedure, as the error is - procedure is incomplete

type
LPWSAOVERLAPPED_COMPLETION_ROUTINE = procedure ( const dwError, cbTransferred : DWORD; const lpOverlapped : LPWSAOVERLAPPED; const dwFlags : DWORD ); stdcall;
// above out of WinSock2

TWSASock = class(Tobject)
private
FWSAOverlap: WSAOverlapped;
.........
Procedure EventCompleation(Const evError, TransferedSize: DWord; Const Overlapped: PWSAOverlapped; Const Flag: DWord); stdcall;
.........
end;
implementation
..........................................
procedure TWSASock.StartUpEvent;
Var
Count: DWord;
CR: LPWSAOVERLAPPED_COMPLETION_ROUTINE;
begin
CR := @EventCompleation(0, Count, @FWSAOverlap, 0); // error on the end hear
........
end;
.........
procedure TWSASock.EventCompleation(evError, TransferedSize: DWord;
var Overlapped: WSAOverlapped; Flag: DWord);
begin

end;
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: code conflict I cannot see whats wrong
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2016 5:27 AM   in response to: Lex Dean in response to: Lex Dean
Lex Dean wrote:

I'm try to make a winsock2 object as most Delphi programmers cannot
see past Indy including multi threading/overlapping advantages, it
offers a routine to return once the data is transferred for client
and server. This is what I'm trying to implement but I have a code
conflict that I do not understand. I have come to the point where
I'm asking Questions is thier a WinSock2 *.Dll error that the dll has
extra values in the procedure, as the error is - procedure is
incomplete

type
LPWSAOVERLAPPED_COMPLETION_ROUTINE = procedure ( const dwError,
cbTransferred : DWORD; const lpOverlapped : LPWSAOVERLAPPED; const
dwFlags : DWORD ); stdcall; // above out of WinSock2

TWSASock = class(Tobject)
private
FWSAOverlap: WSAOverlapped;
.........
Procedure EventCompleation(Const evError, TransferedSize: DWord;
Const Overlapped: PWSAOverlapped; Const Flag: DWord); stdcall;
......... end;
implementation
..........................................
procedure TWSASock.StartUpEvent;
Var
Count: DWord;
CR: LPWSAOVERLAPPED_COMPLETION_ROUTINE;
begin
CR := @EventCompleation(0, Count, @FWSAOverlap, 0); // error on the
end hear ........
end;
.........
procedure TWSASock.EventCompleation(evError, TransferedSize: DWord;
var Overlapped: WSAOverlapped; Flag: DWord);
begin

end;

It's very simple TWSASock.EventCompleation is not compatible with CR.
CR expects a procedure while you're trying to assign a method to it.
Your code should be something like this:

procedure EventCompleation(evError, TransferedSize: DWord; var
Overlapped: WSAOverlapped; Flag: DWord); stdcall;
 begin
 
 end;
 
procedure TWSASock.StartUpEvent;
 Var 
     Count: DWord;
     CR: LPWSAOVERLAPPED_COMPLETION_ROUTINE;
 begin
  CR := @EventCompleation(0, Count, @FWSAOverlap, 0); // error on the
 end hear   ........
 end;
 
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: code conflict I cannot see whats wrong
Click to report abuse...   Click to reply to this thread Reply
  Posted: Aug 18, 2016 10:12 AM   in response to: Lex Dean in response to: Lex Dean
Lex wrote:

I'm try to make a winsock2 object

WinSock has nothing to do with the OpenTools API. You should ask in the
WinSock forum instead.

most Delphi programmers cannot see past Indy

Hardly. Indy is popular, partly because it is bundled with Delphi itself.
But there are many other socket libraries available that are just as popular
(ICS, Synapse, etc).

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02