Solved

Communication between two programs

Posted on 2006-07-02
12
358 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
  • 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
 

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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 500 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now