Using socket communication within classes

TomBlue999

New Member
Hi folks!

I have a tricky problem with socket communication and classes. It is a fact that it is not possible to use input blocking statements (PROPMT-FOR, SET, UPDATE, WAIT-FOR, READKEY and PROCESS EVENTS) within user-defined functions. That means it is also not possible to use this statement within methods of classes. (Explanation: When using this statements progress error 2780 is raised at runtime)

I have major part of business logic within classes and some of them have to call procedures using TCP socket communication for SMTP mail and communication with 3rd party servers. This is not possible because of mentioned progress restriction.

Does anyone have an idea or workaround how to use socket communication within classes?

Thanks a lot,

Thomas
 
I don't know the situation, but is it possible that input blocking statements are not necessary for your socket communication? Maybe you could get away without using them.

Otherwise maybe you could move the socket logic to a separate .p file and run the .p file.
 
Hi D.Cook!

Thanks for reply. Please see my comments:

I don't know the situation, but is it possible that input blocking statements are not necessary for your socket communication? Maybe you could get away without using them.
Yes, but I do not find any possibility to use socket communication without using WAIT-FOR statement, do you?

Otherwise maybe you could move the socket logic to a separate .p file and run the .p file.
This is not working, Progress recognizes this at runtime and raises error 2780 as well.
 
It sounds as though your ABL code is performing the actions of a client, not server, therefore your methods would probably simply send a command, then read the response. The WRITE and READ functions are blocking (which means the processing will pause until either the buffer is full or the connection is closed) therefore a wait-for is unnecessary.
However if this is not the case, it seems that you'll have to re-structure your code outside of a class.
 
I didn't think about omiting the "WAIT-FOR". It is used in any examples I've seen yet, even on client side (yes, you're right).

I'm going to give this a try,
Thanks a lot!
 
Socket communication work wery well with classes.
pro -p NewClassTest.p

But is a trick .. take a look to smtpmail.p ... search WAIT-FOR , you will understand :)
 

Attachments

Yes, your example is working. But - sorry - I missed an additional information in my explanation of the problem.

Error 2780 is thrown only when SMTPMAIL.p (or other socket communication procedure) is called from a method declared as any datatype except VOID. When changing your examples like below, it is not working:

/* File: classTest.cls */
CLASS classTest :
DEF VAR oSuccessful AS LOGICAL NO-UNDO.
DEF VAR vMessage AS CHARACTER NO-UNDO.
CONSTRUCTOR PUBLIC classTest():
END CONSTRUCTOR.
METHOD PUBLIC INTEGER SendMail (lRecipient as char):
RUN globals/smtpmail.p (
INPUT "mail.dot.com", /*mailhub*/
INPUT lRecipient, /*EmailTo*/
INPUT recipient@dot.com, /*EmailFrom*/
INPUT "",/*EmailCC*/
INPUT "", /*Attachments*/
INPUT "", /*LocalFiles*/
INPUT "Subject", /*Subject*/
INPUT "body", /*Body*/
INPUT "type=text/html:charset=us-ascii:filetype=ascii", /*MIMEHeader*/
INPUT "text", /*BodyType*/
INPUT 3, /*Importance*/
INPUT false, /*doAUth*/
INPUT "base64",
INPUT "",
INPUT "",
OUTPUT oSuccessful, /*oSuccessful*/
OUTPUT vMessage ). /*vMessage*/
MESSAGE oSuccessful.
MESSAGE vMessage.
RETURN 0.
END METHOD.
END CLASS.

-----------

/* File: NewClassTest.p */
DEFINE VARIABLE goTest AS CLASS classTest NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
goTest = new classTest().
i = goTest:SendMail(recipient@dot.com).

Of course it is no problem to workaround in mail class itself, but I cannot workaround this issue for whole application. I.e: Any webservice is using class A using method AA declared as void, this class is using another class B using method BB declared as char. If this method now is calling any procedure using WAIT-FOR (i.e. smtpmail.p, error 2780 is thrown. Does this make sense?
The only workaround would be always to use methods declared as void - this is not possible and also not useful.

I already have started to change smtpmail.p not using "WAIT-FOR" like D.Cook suggested. I'm going to post again if I get any results. (Until now anything is alright when there is no error with mailserver, I still have to check any error conditions).

Thanks a ton!
 
I already had contact to tech support with this issue. They've said it is a "feature";). It also could be that they didn't understand what I mean :confused:. In Austria it gets more and more difficult to get good contact to progress. It seems that our country or my comapny is too small for these guys.
 
Back
Top