🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
7 messages
7 total messages Started by Quentin David Jones Thu, 07 Dec 2006 05:46
ASync Lookup for ServerSocket in non-blocking ?
#1588
Author: Quentin David Jones
Date: Thu, 07 Dec 2006 05:46
43 lines
2380 bytes
Greetings all,

Well, I have found the Internet Chat example from Borland quite helpful. I 
split it into a separate server and client and made the server simply 
receive a file name from the client and return it's date/time, (and removed 
all UI from the server.) Works fine.

Now,
I am trying to convert the server into a SERVICE. I can build the service 
and get it to install and start/stop etc.

But,
I get an error like so upon running the service in non-blocking mode 
(blocking mode gives no error and no results) :

ERROR MSG:
" Windows socket error: The requested name is valid and was found in the 
database, but it does not have the correct associated data being resolved 
for (11004), on API 'ASync Lookup' "

Apparently, this means I need to set the ASyncStyles property of 
TCustomWinSocket to include the events I want to handle.

But I am not sure how to do this - the help defines it like so:

<Code begins>

enum TAsyncStyle { asRead, asWrite, asOOB, asAccept, asConnect, asClose };
typedef Set<TAsyncStyle, asRead, asClose>  TAsyncStyles;
__property TAsyncStyles ASyncStyles = {read=FAsyncStyles, 
write=SetAsyncStyles, nodefault};

<Code ends>

How do I set these ASyncStyles please?
I tried an assignment, I tried using SetASyncStyles, I included sysset.h
Can not get it to work.

Also - on which event should I set these?

Regards,

Quentin
Re: ASync Lookup for ServerSocket in non-blocking ?
#1589
Author: Quentin David Jones
Date: Thu, 07 Dec 2006 06:32
54 lines
2797 bytes
Hmmm...

Seems to be related to a problem with the local IP address ?

Q.


"Quentin David Jones" <quentin.jones@romteck.com.spamprotect> wrote in 
message news:4577aa78@newsgroups.borland.com...
> Greetings all,
>
> Well, I have found the Internet Chat example from Borland quite helpful. I 
> split it into a separate server and client and made the server simply 
> receive a file name from the client and return it's date/time, (and 
> removed all UI from the server.) Works fine.
>
> Now,
> I am trying to convert the server into a SERVICE. I can build the service 
> and get it to install and start/stop etc.
>
> But,
> I get an error like so upon running the service in non-blocking mode 
> (blocking mode gives no error and no results) :
>
> ERROR MSG:
> " Windows socket error: The requested name is valid and was found in the 
> database, but it does not have the correct associated data being resolved 
> for (11004), on API 'ASync Lookup' "
>
> Apparently, this means I need to set the ASyncStyles property of 
> TCustomWinSocket to include the events I want to handle.
>
> But I am not sure how to do this - the help defines it like so:
>
> <Code begins>
>
> enum TAsyncStyle { asRead, asWrite, asOOB, asAccept, asConnect, asClose };
> typedef Set<TAsyncStyle, asRead, asClose>  TAsyncStyles;
> __property TAsyncStyles ASyncStyles = {read=FAsyncStyles, 
> write=SetAsyncStyles, nodefault};
>
> <Code ends>
>
> How do I set these ASyncStyles please?
> I tried an assignment, I tried using SetASyncStyles, I included sysset.h
> Can not get it to work.
>
> Also - on which event should I set these?
>
> Regards,
>
> Quentin
>
> 
Re: ASync Lookup for ServerSocket in non-blocking ?
#1590
Author: Remy Lebeau (TeamB)
Date: Thu, 07 Dec 2006 07:27
32 lines
2018 bytes
"Quentin David Jones" <quentin.jones@romteck.com.spamprotect> wrote in
message news:4577aa78@newsgroups.borland.com...

> I get an error like so upon running the service in non-blocking mode
> (blocking mode gives no error and no results) :

Please show your actual code.

> " Windows socket error: The requested name is valid and was found in
> the database, but it does not have the correct associated data being
> resolved for (11004), on API 'ASync Lookup' "

Services run in the SYSTEM account by default, which does not have access to
the network.  Try configuring the service to run in a user account that has
network permissions.

> Apparently, this means I need to set the ASyncStyles property of
> TCustomWinSocket to include the events I want to handle.

That is done for you automatically by simply setting the server into
non-blocking mode.

> How do I set these ASyncStyles please?

You can't set it manually.

P.S. please stop cross-posting.  It is against Borland's newsgroup
guidelines (http://info.borland.com/newsgroups).


Gambit
Re: ASync Lookup for ServerSocket in non-blocking ?
#1591
Author: Quentin David Jones
Date: Thu, 07 Dec 2006 07:44
23 lines
1642 bytes
Greetings,

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:4577c2eb$1@newsgroups.borland.com...

> Services run in the SYSTEM account by default, which does not have access 
> to
> the network.  Try configuring the service to run in a user account that 
> has
> network permissions.

Ah, that sounds like the problem, I'll try that before posting code.


> P.S. please stop cross-posting.  It is against Borland's newsgroup
> guidelines (http://info.borland.com/newsgroups).

Sorry, will use sockets group only for this.

Thanks Remy.
(Do you spend all day helping people? :-)

Q.
Indy 10: Send a file with TIdTCPClient
#1592
Author: David
Date: Thu, 07 Dec 2006 09:06
26 lines
1562 bytes
I have a little proble when try to send a file with component TIdTCPClient.

My procedure is:

Client unit:

TCPClient.IOHandler.WriteLn(FileName);
TCPClient.IOHandler.WriteFile(FileName);


Server unit:

FStream := TFileStream.Create(NomeFile, fmCreate, fmOpenWrite);
AContext.Connection.IOHandler.LargeStream := True;
AContext.Connection.IOHandler.ReadStream(FStream);
FreeAndNil(FStream);

The problem is the error "Socket Error 10053" when the WriteFile 
function is executed.

Someone have some idea to solve this? (Or some example)

Thanks,
David

Ps. Sorry for my English - I'm Italian
Re: Indy 10: Send a file with TIdTCPClient
#1594
Author: Remy Lebeau (TeamB)
Date: Thu, 07 Dec 2006 10:34
64 lines
2773 bytes
"David" <microges@email.it> wrote in message
news:4577d988$1@newsgroups.borland.com...

> TCPClient.IOHandler.WriteLn(FileName);

You shouldn't be sending the full file path, only the file name:

    TCPClient.IOHandler.WriteLn(ExtractFileName(FileName));

> TCPClient.IOHandler.WriteFile(FileName);

Try using Write(Stream) instead.

> FStream := TFileStream.Create(NomeFile, fmCreate, fmOpenWrite);

Where and how is NomeFile assigned?

> AContext.Connection.IOHandler.LargeStream := True;

Did you set LargeStream to True on the client side?

> AContext.Connection.IOHandler.ReadStream(FStream);

By default, ReadStream() reads an integer value (an Int64 in this case
because you set LargeStream to True) specifying the number of stream bytes
being sent.  However, WriteFile() does not send that value.  So you are
corrupting your file transfer.  If you are going to use ReadStream() like
that, then you have to call Write(Stream) on the client side instead of
WriteFile().  For example:

    --- Client ---

    uses
        IdGlobal, IdObjs, IdSys;

    var
        Stream: TIdStream;
    begin
        Stream := TIdReadFileExclusiveStream.Create(FileName);
        try
            TCPClient.IOHandler.WriteLn(ExtractFileName(FileName));
            TCPClient.IOHandler.LargeStream := True;
            TCPClient.IOHandler.WriteStream(Stream, 0, True);
        finally
            Sys.FreeAndNil(Stream);
        end;
    end;


    --- Server ---

    NomeFile := 'C:\Some Folder\' +
ExtractFileName(AContext.Connection.IOHandler.ReadLn);
    FStream := TIdFileCreateStream.Create(NomeFile);
    try
        AContext.Connection.IOHandler.LargeStream := True;
        AContext.Connection.IOHandler.ReadStream(FStream);
    finally
        Sys.FreeAndNil(FStream);
    end;


Gambit
Re: ASync Lookup for ServerSocket in non-blocking ?
#1596
Author: Quentin David Jones
Date: Fri, 08 Dec 2006 00:02
15 lines
1428 bytes
Hi all,

Back at work (GMT-9 here :-)

I fixed that problem - not the use name after all, I had simply left 
something out.
I am finding it a little confusing working out the division of 
responsibility between OS and application (my background is in small 
real-time embedded systems where it's usually entirely my code.)

Moving on, will post later if next snag is a doozy...

Thanks for help :-)

Q.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads