VB to call and get return value from C++ functions on Unix

Dear experts,

Am working on VB application intended to access Unix and get information on system status, unix process/thread information(my sets of C++ programs) and able to get the return value from the Unix builtin functions or my own utilities functions in C++.

1) A sets of C++ functions (resides in UNIX) already built and i want to re-use them.
2) VB application on windows able to 'access/call' the functions in 1)
3) if direct function calling 2) is not achievable, any other alternatives?
4) Is there a way to expose C/C++ functions as object in Unix, and let Window appl to access via TCP and perhaps instantiate an object, just like java RMI(but i dun prefer Java) for this project.
5) Sample code if any

Thanks very much! Your kind advise is very much appreciated


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Most Unix boxes run rexec daemon on port 512 for remote execution of commands. You can connect to the rexec port and have the results of the command returned to VB. You can accomplish this using the winsock control. I'll see if I can throw an example together.
Here's a simple example. Add a Winsock control, a Textbox called Text1, a Textbox called Text2 with the Multiline Property set to True and 2 command buttons to a form.

Then paste this into the form and edit the machine ip,username and password.

To use the example type the command into Text1 and then click Command1.The results of the command should be in Text2.
To disconnect click Command2.

Private Sub Command1_Click()
    Winsock1.RemotePort = 512
    Winsock1.RemoteHost = "" ' unix machine
End Sub

Private Sub Command2_Click()  ' close connection
End Sub

Private Sub WinSock1_Connect()
    Text2.Text = ""
    sendData Text1.Text, "vinny", "mypassword"
End Sub

Private Sub sendData(rsData As String, Optional rsUserId As String, Optional rsPwd As String)
Dim lRet As Long
    Winsock1.sendData (Chr(0))
    If Not IsMissing(rsUserId) Then
        Winsock1.sendData rsUserId & Chr(0)
    End If
    If Not IsMissing(rsPwd) Then
        Winsock1.sendData rsPwd & Chr(0)
    End If
    Winsock1.sendData rsData & Chr(0)
End Sub

Private Sub WinSock1_DataArrival(ByVal bytesTotal As Long)
    Dim sData As String
    Winsock1.GetData sData, vbString
    Text2.Text = Text2.Text & vbCrLf & sData
    Text2.Text = Replace(Text2.Text, vbLf, vbCrLf)
End Sub

Private Sub WinSock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
    MsgBox Description, vbInformation, "reporting communication error"
End Sub
kluylAuthor Commented:

1) how do check if the rexec is running on Unix ? If not, how do i set it up?
2) do i get the return value of C functions in Unix via sData as above mentioned?
for instance, i hv a own function that return a 'Y' or 'N' ..char check_serv_start(char* servtype); residing in Unix. This sData wil able to tell me the return value of check_serv_start(char* servtype)?

Please advise. Thanks.

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

kluylAuthor Commented:

result if i run  ps -ef | grep rexecd =
  lnvdev 27742 39492   1 18:03:52  pts/0  0:00 grep rexecd

kluylAuthor Commented:
What happened? Are you still there?

Pls do something... Are we going to stop here?

Although this multi-part question was not answered in full, and the Expert did not return to provide needed additional help, I feel that the code posted answered an important part of the question and is thus PAQworthy.
-- DanRollins, EE Cleanup Volunteer
kluylAuthor Commented:

Am very disappointed with your comment. I hv been SOS for answer since 13-Apr, but the it was deserted or ignored, however you described it. After 1 month, then you now just pop-up and say i'm not responsible?? Please be rational.

PAQed with points refunded (500)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.