[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Communication between two programs

Posted on 2006-07-02
12
Medium Priority
?
375 Views
Last Modified: 2013-11-13
Hello everyone!

I have an urgent problem.  I have made a program that processes and records data at a business which has two locations.  I need to figure out how to make the programs send files back and forth to one another daily.  Can anyone help me!?!

Thanks!
Banks
0
Comment
Question by:zraptor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
  • 2
  • +2
12 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 17029018
Hi Banks

You have to provide a little bit more information.
What database?
Are the two companies connected to the internet, or to each other is some way or other?


Dabas
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17029078
you can use winsock in doing this...
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17029082
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:zraptor
ID: 17029100
The program needs to be able to send the database file it creates to the program at the other location.  Both locations have access to the internet.

I will check out that tutorial.
0
 
LVL 27

Expert Comment

by:Dabas
ID: 17029120
zraptor,
You have not answered my first question. What database? MSAccess mdb? SQL Server? Whjcjh version?
Sending the database file can be inpractical, specially if it is large.
If SQL Server then replication might be given serious consideration.

Dabas
0
 
LVL 9

Expert Comment

by:Naveen Swamy
ID: 17029123
you need to be clear about what you want, the scope of the question is very wide,

some of the available options are :

1) Ado can handle remote ips and database connectivity, (whole lot of examples available already on the net )
2) Winsocks to t/f data (refer www.vbip.com)
0
 

Author Comment

by:zraptor
ID: 17029818
The database's are Excel spreadsheets.  I need both programs to be able to send the spreadsheets to each other directly.  I don't want to use a FTP server on the internet or anything like that, I need to be able to send the files directly to the other computer.
0
 
LVL 15

Accepted Solution

by:
JackOfPH earned 2000 total points
ID: 17034721
here is the code in which you can send files across a network... just create two projects server and client. make both .exe

sorry here is the code...

Here's the client..it has a timer , a winsock control, a commondialog control, two textboxes, and three buttons.

***************************begin client ***********************
Option Explicit
Private Sub Command1_Click()
   If cliSock.State <> 0 Then
       cliSock.Close
   End If
   Unload Me
End Sub

Private Sub Command2_Click()
cliSock.Connect Text1.Text, Text2.Text
End Sub

Private Sub Command3_Click()
Dim filename As String
On Error GoTo errhan
   'open a file, and send it to the client as binary
   CommonDialog1.ShowOpen
   filename = CommonDialog1.filename
   Dim str() As Byte
   Open filename For Binary As #1
   ReDim str(FileLen(filename))
   Get #1, , str
   Close #1
   cliSock.SendData str
   Exit Sub
errhan:
msgbox "error"
End Sub



Private Sub Timer1_Timer()
 Select Case cliSock.State
Case 0
   Me.Caption = "Closed"
Case 1
   Me.Caption = "Open"
Case 2
   Me.Caption = "Listening"
Case 3
   Me.Caption = "Connection pending"
Case 4
   Me.Caption = "Resolving host"
Case 5
   Me.Caption = "Host resolved"
Case 6
   Me.Caption = "Connecting"
Case 7
   Me.Caption = "Connected"
Case 8
   Me.Caption = "Peer is closing the connection"
Case 9
   Me.Caption = "Error"
End Select
End Sub


********************end client *******************************
create a new projects...
Here's a server:
It's got a winsock control, a textbox, a timer, and two command buttons.

******************start server********************************
Option Explicit
Dim x As Long       'Byte counter variable
Dim str() As Byte   'Byte variable

Private Sub Command1_Click()
  'Check the connection state before closing
   If svrsock.State <> 0 Then
       svrsock.Close
   End If
   Unload Form1
   Unload Me
End Sub


Private Sub Command2_Click()
svrsock.LocalPort = Text1.Text 'Set the local port to listen on
svrsock.Listen
End Sub

Private Sub Form_Load()
'Command1.Top = Me.ScaleHeight - Command1.Height
x = 1
End Sub

Private Sub Form_Resize()
'Command1.Top = Me.ScaleHeight - Command1.Height
End Sub

Private Sub Form_Unload(Cancel As Integer)
   Unload Form1

End Sub

Private Sub svrSock_ConnectionRequest(ByVal requestID As Long)
svrsock.Close             'Close the socket
svrsock.Accept requestID  'Accept incoming call
End Sub

Private Sub svrSock_DataArrival(ByVal bytesTotal As Long)
      On Error GoTo errhan
       svrsock.GetData str, vbArray + vbByte        'get binary data
       Open App.Path & "\tempfile" For Binary As #1 'open a tempfile for storage
       Put #1, x, str                               'Start creating file at first Byte
       Close #1                                     'Close the file
       x = (x + 1) + UBound(str) ' This counter is to save the last byte stroed in the file and resume
       Command1.Caption = x
       Exit Sub
errhan:
      MsgBox Err.Number & Err.Description
End Sub

Private Sub Timer1_Timer()
 Select Case svrsock.State
Case 0
   Me.Caption = "Closed"
Case 1
   Me.Caption = "Open"
Case 2
   Me.Caption = "Listening"
Case 3
   Me.Caption = "Connection pending"
Case 4
   Me.Caption = "Resolving host"
Case 5
   Me.Caption = "Host resolved"
Case 6
   Me.Caption = "Connecting"
Case 7
   Me.Caption = "Connected"
Case 8
   Me.Caption = "Peer is closing the connection"
   svrsock.Close
   svrsock.Listen
Case 9
   Me.Caption = "Error"
End Select
End Sub




*******************end server********************************

0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17034726
I use winsock control because it is the simplest... but if you want to use the winsock.dll just go to www.vbip.com they have tutorials on what you need...

0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 17034766
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 17036921
What you might want to think about is simply uploading this information to a FTP website along with a bogus text file the text file acts as an indicator to the other application that its ready to download the file on the other end. When the transfer is complete remove the file.

You can use WinInet API's to access data over an http or ftp url.
0
 
LVL 29

Expert Comment

by:nffvrxqgrcfqvvc
ID: 17036937
<<< I don't want to use a FTP server on the internet or anything like that, I need to be able to send the files directly to the other computer.

I  missed that part, however you might want to reconsider this option. It's secure and most reliable and offers a backup method.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question