Answered by:
Copy a text file from one computer to another

Question
-
Hello,
I'm working on project where a central server is connected through TCP-IP to several client computers (roughly 30 computers). I want to transfer text files from the clients to the server, without user intervention. The clients know what is the server name. The server knows each IP adress of each client (fixed addresses). Both clients and server have .net Framework 4 installed.
I'd like to evaluate my various options. Please let me know what is the best choice.
1) Develop a program residing on the client computers which will copy the files from a local directory to a server directory. I'm thinking of using the IO.File.Copy method. Is it possible ? Does this require any specific setting (security setting) on the server ? On the clients ?
2) Develop a program residing on the server which will copy the file from each client in turn to a central directory. Is it possible to use an IP address in an IO.File.Copy method ?? Does that require any security setting on the clients ? If yes, can it be automatized ? Does it require any security setting on the server ?
3) Any other idea ??
Thanks
Monday, February 4, 2013 12:13 PM
Answers
-
Reed,I have never used this ... How does this work ? Do you have, by chance, a code example ?
How would then security issues be addressed ? (I'm sure the communication has to go through some kind of credentials verification ?).
Thanks
Dude I gave you a link to a TCP Server/Client program Here so you can read up on how it works. But it's probably designed for manual addition of files to the client for sending to the server or vice versa I'm fairly certain.
No credentials would be required.
But you would probably have to alter the code so that a file system watcher could automatically pass files to the clients application for transmission to the server whenever the clients user placed a file in a certain folder.
If you want I can post a TCP Transmitter and TCP Receiver for you that you can test between two computers (as long as you know their addresses) and send basic text from the TCP Transmitter to the TCP receiver. Very small applications and easy to copy/paste into a couple of seperate WinForm apps. Which will show you that no credentials are required.
On the other hand my computers firewall doesn't realize the my TCP receiver is an authorized application so it always trys to block it on start up but asks me if I want to allow the TCP receiver to have access. This of course can be alleviated by adding the TCP receiver as an authorized application in the firewall which I haven't done.
But no "credentials" are necessary to use either one.
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Tuesday, February 5, 2013 8:09 AM -
Or you could add a TcpListener to the server application and have the client application use a TcpClient to open a connection to the server and pass the file data without worrying about windows file security.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
Reed,
I have never used this ... How does this work ? Do you have, by chance, a code example ?
How would then security issues be addressed ? (I'm sure the communication has to go through some kind of credentials verification ?).
Thanks
Here's what the TCP transmitter and TCP receiver look like in operation. Although the transmitter sends data to the receiver with no problem the data never goes out onto the network in my instance because it loops back in an IP stack layer before ever departing my machine since both applications are using my same physical IP address.
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Tuesday, February 5, 2013 8:21 AM -
Here's a TCP Transmitter and a TCP Receiver.
Note in the Images for each that the first two boxes are textboxes and the second two are richtextboxes on each form. Labels should be self explanatory. Buttons too.
Also the IP address can just be typed over with a new IP address prior to transmission or reception. So the transmitter would have the IP address of the computer it is on and the receiver would have the IP address of the computer it is on. The transmitter needs to transmit on the same logical port that the receiver is listening on. You can use logical port 8004 as it is unassigned for any particular use instead of logical port 8000 which I hard coded and is supposed to be used for some non descript app.
First Code Block is transmitter.
Imports System.Net.Sockets Imports System.Text Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load TextBox1.Text = "192.168.0.13" TextBox2.Text = "8000" End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim tcpClient As New System.Net.Sockets.TcpClient() Try tcpClient.Connect(TextBox1.Text, TextBox2.Text) Dim networkStream As NetworkStream = tcpClient.GetStream() If networkStream.CanWrite And networkStream.CanRead Then Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(RichTextBox2.Text) networkStream.Write(sendBytes, 0, sendBytes.Length) Dim bytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) Dim returndata As String = Encoding.ASCII.GetString(bytes) RichTextBox1.AppendText("Host returned: " & returndata & vbCrLf) Else If Not networkStream.CanRead Then RichTextBox1.AppendText("cannot not write data to this stream" & vbCrLf) tcpClient.Close() Else If Not networkStream.CanWrite Then RichTextBox1.AppendText("cannot read data from this stream" & vbCrLf) tcpClient.Close() End If End If End If Catch ex As Exception RichTextBox1.AppendText(ex.Message & vbCrLf) End Try End Sub Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged End Sub Private Sub RichTextBox2_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox2.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click End Sub Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click End Sub End Class
Now the receiver
Imports System.Net.Sockets Imports System.Text Imports System.Net Public Class Form1 'http://www.eggheadcafe.com/articles/20020323.asp Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load TextBox1.Text = "192.168.0.13" TextBox2.Text = "8000" End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Dim ipAddress As IPAddress = ipAddress.Parse(TextBox1.Text) Dim portNumber As Integer = TextBox2.Text Dim tcpListener As New TcpListener(ipAddress, portNumber) tcpListener.Start() RichTextBox1.AppendText("Waiting for connection..." & vbCrLf) Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient() RichTextBox1.AppendText("Connection accepted." & vbCrLf) Dim networkStream As NetworkStream = tcpClient.GetStream() Dim bytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) Dim clientdata As String = Encoding.ASCII.GetString(bytes) RichTextBox2.AppendText("Client sent: " & clientdata & vbCrLf) Dim responseString As String = "Connected to server." Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString) networkStream.Write(sendBytes, 0, sendBytes.Length) RichTextBox1.AppendText(vbCrLf & "Message Sent /> : " & responseString) tcpClient.Close() tcpListener.Stop() RichTextBox1.AppendText("exit") Catch ex As Exception RichTextBox1.AppendText(ex.Message) End Try End Sub Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged End Sub Private Sub RichTextBox2_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox2.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click End Sub Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click End Sub End Class
Now the Images so you can create similiar Forms for each
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Tuesday, February 5, 2013 8:48 AM -
Mr MonkeyBoy,
Thanks, thanks and thanks again !
Please allow me some time to read, understand and copy all this.
Will be back !!
I did a change up on you. Now I made the TCP Transmitter and TCP Receiver to transmit and receive files. I transmitted and received a .txt file, a .wmv file and a .exe file (Notepad) to verify no problems with the received files.
First is the TCP Transmitter code, then the TCP Receiver code and finally the Images.
Imports System.Net.Sockets Imports System.Text Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load TextBox1.Text = "192.168.0.13" TextBox2.Text = "8004" End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim tcpClient As New System.Net.Sockets.TcpClient() Try tcpClient.Connect(TextBox1.Text, TextBox2.Text) Dim networkStream As NetworkStream = tcpClient.GetStream() If networkStream.CanWrite And networkStream.CanRead Then Dim TXFileSize As String TXFileSize = CStr(FileLen(TextBox3.Text)) Dim SendTXFileSize As [Byte]() = Encoding.ASCII.GetBytes(TXFileSize) networkStream.Write(SendTXFileSize, 0, SendTXFileSize.Length) Dim TXBytes() As Byte TXBytes = My.Computer.FileSystem.ReadAllBytes(TextBox3.Text) networkStream.Write(TXBytes, 0, TXBytes.Length) Dim RXbytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(RXbytes, 0, CInt(tcpClient.ReceiveBufferSize)) Dim returndata As String = Encoding.ASCII.GetString(RXbytes) RichTextBox1.AppendText("Host returned: " & returndata & vbCrLf) Else If Not networkStream.CanRead Then RichTextBox1.AppendText("cannot not write data to this stream" & vbCrLf) tcpClient.Close() Else If Not networkStream.CanWrite Then RichTextBox1.AppendText("cannot read data from this stream" & vbCrLf) tcpClient.Close() End If End If End If Catch ex As Exception RichTextBox1.AppendText(ex.Message & vbCrLf) End Try End Sub Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged End Sub Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click End Sub Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click End Sub End Class
Imports System.Net.Sockets Imports System.Text Imports System.Net Public Class Form1 'http://www.eggheadcafe.com/articles/20020323.asp Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load TextBox1.Text = "192.168.0.13" TextBox2.Text = "8004" TextBox3.Text = "C:\Users\John\Desktop\Test.wmv" End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Dim ipAddress As IPAddress = ipAddress.Parse(TextBox1.Text) Dim portNumber As Integer = TextBox2.Text Dim tcpListener As New TcpListener(ipAddress, portNumber) tcpListener.Start() RichTextBox1.AppendText("Waiting for connection..." & vbCrLf) Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient() RichTextBox1.AppendText("Connection accepted." & vbCrLf) Dim FileSize As NetworkStream = tcpClient.GetStream() Dim bytes(tcpClient.ReceiveBufferSize) As Byte FileSize.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) Dim clientdata As String = Encoding.ASCII.GetString(bytes) clientdata = CStr(CInt(clientdata) - 1) Dim File As NetworkStream = tcpClient.GetStream() Dim FileLength(CInt(clientdata)) As Byte File.Read(FileLength, 0, CInt(clientdata)) 'this worked for pegasus.wmv My.Computer.FileSystem.WriteAllBytes(TextBox3.Text, FileLength, False) Dim responseString As String = "Connected to server." Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString) File.Write(sendBytes, 0, sendBytes.Length) RichTextBox1.AppendText(vbCrLf & "Message Sent /> : " & responseString) tcpClient.Close() tcpListener.Stop() RichTextBox1.AppendText("exit") Catch ex As Exception RichTextBox1.AppendText(ex.Message) End Try End Sub Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged End Sub Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click End Sub Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click End Sub End Class
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Tuesday, February 5, 2013 11:33 PM -
First of all you can not connect two computers with a standard ethernet cable. You have to have either an ethernet crossover cable or connect both computers to a minihub which acts as a bridge. So I don't know how you're able to ping each computer. Also the program will not freeze while in receive mode or transmit mode except during transmission of really large data like my 122MB .Wav file but the transmission and reception only takes a couple of seconds anyhow.
Also you have to configure the IP stacks of each computer with the correct IP address of the computer and the correct subnet mask. And the correct IP stack layers to support hardcoded IP address/subnet mask/non-DHCP, etc which I don't know how to do on my Win7 laptop cause I never had a reason to try.
Below is the pinout for an RJ-45 jack for an ethernet crossover cable.
1tx+ to +rx3
2tx- to -rx7
3rx+ to +tx1
7rx- to -tx2
You've taught me everything I know but not everything you know.
- Edited by Mr. Monkeyboy Wednesday, February 6, 2013 4:52 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 4:32 PM -
Sygrien, when you get done send me the source because I work in the k-12 sector on computers in a IT department but my focus is mostly coding software/scripts with some hardware in-between from time to time. I can help you link it up with infinite campus. I have done many NDA beta tests on software/games too so I can keep a secret. We just upgraded our POS machines to windows 7 so its a great time to test drive something new. my work email is jeffery.carlson@garrard.kyschools.us
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr
- Edited by The Thinker Wednesday, February 6, 2013 7:34 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 7:28 PM -
The first question you need to anser is if you want to make the file system on the computer shared. If you do the answer if simple becuase you can copy to the computer name like
\\computer abc\c\myfolder\abc.txt.
Depending on the access rights to the computer will depend if you can copy the files. If both computers use the same group policies then you should be able to copy the files. To enble sharing right click on the folder(s) you want to be shared and select properties from a window exploere.
If you don't want to make the file shared then you could use the class FTPWEbRequest to transfer files.
jdweng
- Marked as answer by Sygrien Thursday, February 7, 2013 3:29 PM
Monday, February 4, 2013 12:22 PM -
This looks pretty good and I'm sure the software could be made to use file system watcher to auto detect new files on the clients and transmit them to the server. Don't know how the code works or how it knows what to name files received from the clients. But it's TCP based. Any how it's at Code Project and looks like something you could use.
On the other hand if the systems are already networked together to allow sharing it seems that you could just use a file system watcher to monitor each clients folder then use one of the copy commands to copy a new file from a client to a specified server folder.
You've taught me everything I know but not everything you know.
- Edited by Mr. Monkeyboy Monday, February 4, 2013 12:48 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:29 PM
Monday, February 4, 2013 12:34 PM -
Heres an example of a, probably not well written, file system watcher watching the folder C:\Users\John\Desktop\Test1 and whenever a file is added to it the file is autocopied to C:\Users\John\Desktop\Test2 by the application.
Imports System.IO Imports System.Diagnostics Public Class Form1 Public watchfolder As FileSystemWatcher Dim FilePathFrom As String = "" Dim FilePathTo As String = "" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Control.CheckForIllegalCrossThreadCalls = False txt_WatchPath.Text = "C:\Users\John\Desktop\Test1" End Sub Private Sub txt_WatchPath_TextChanged(sender As Object, e As EventArgs) Handles txt_WatchPath.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles txt_FolderActivity.TextChanged End Sub Private Sub btn_StartWatch_Click(sender As Object, e As EventArgs) Handles btn_StartWatch.Click watchfolder = New System.IO.FileSystemWatcher() watchfolder.Path = txt_WatchPath.Text watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.FileName watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.Attributes AddHandler watchfolder.Changed, AddressOf logchange AddHandler watchfolder.Created, AddressOf logchange AddHandler watchfolder.Deleted, AddressOf logchange AddHandler watchfolder.Renamed, AddressOf logrename watchfolder.EnableRaisingEvents = True btn_StartWatch.Enabled = False btn_Stop.Enabled = True End Sub Private Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs) If e.ChangeType = IO.WatcherChangeTypes.Changed Then txt_FolderActivity.Text &= "File " & e.FullPath & " has been modified" & vbCrLf End If If e.ChangeType = IO.WatcherChangeTypes.Changed Then Me.Text = FileLen(e.FullPath) End If If e.ChangeType = IO.WatcherChangeTypes.Created Then txt_FolderActivity.Text &= "File " & e.FullPath & " has been created" & vbCrLf Dim Test As String = e.FullPath.ToString() Test = Test.Remove(26, 1) Test = Test.Insert(26, "2") FilePathFrom = e.FullPath.ToString() FilePathTo = Test CopyingFile() End If If e.ChangeType = IO.WatcherChangeTypes.Deleted Then txt_FolderActivity.Text &= "File " & e.FullPath & " has been deleted" & vbCrLf End If End Sub Public Sub logrename(ByVal source As Object, ByVal e As System.IO.RenamedEventArgs) txt_FolderActivity.Text &= "File" & e.OldName & " has been renamed to " & e.Name & vbCrLf End Sub Private Sub btn_Stop_Click(sender As Object, e As EventArgs) Handles btn_Stop.Click watchfolder.EnableRaisingEvents = False btn_StartWatch.Enabled = True btn_Stop.Enabled = False End Sub Private Sub CopyingFile() btn_Stop.PerformClick() FileCopy(FilePathFrom, FilePathTo) txt_FolderActivity.Text &= "File " & FilePathFrom & " Copied to " & FilePathTo & vbCrLf btn_StartWatch.PerformClick() End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub End Class
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:29 PM
Monday, February 4, 2013 1:51 PM -
Is it your application that has created the TCP/IP connection between the client(s) and the server?
If so, you already have a connection so why not use it? Just have the clients pass the file data over the current connection. Depending on how you use the connection you might have to extend your protocol to indicate what kind of transfer is occuring.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 5:01 PM -
Thank you Mr MonkeyBoy for this piece of code.
I think your code copies files on the same computer. My problem is to copy files from one computer to another.
My questions are :
1) Do I need to create shared directories ?
2) Do I need to set the two computers on the same WorkGroup ? On the same domain ?
3) Do I need to create a specific userID and password on the receiving computer ?
4) Can I use an IP address in a File.Copy command ?
5) Do I need to specify a userID and a password in the File.Copy command ? How ?
That code I displayed copies a file at a time and would need to be altered to be of any real value.
1) I've been out of this type of networking for sometime and am unsure what the best scenario for you is.
2) as a test you can set the two computers in the same workgroup with file sharing allowed. This may not be a good route as far as security in a real world environment though. Don't know about the domain issue. That software I displayed can copy files on a workgroup from one computer to another if filesharing is established.
3) Don't know.
4) Don't think so but with that TCP software link I provided that would be unecessary AFAIK.
5) Don't know.
Since this is a VB.Net forum and not a Microsoft Windows Networking forum I recommend further research for you.
"Microsoft Windows is the most installed desktop operating system on the planet. In this section, you will learn Windows tips and tricks, networking how-tos, system administration, software development, data recovery, and more. "
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 5:32 PM -
I would first try copying the file using a window explorer before trying with DOS (cms.exe). with cmd.exe there are sometimes issues with file name when they have spaces. In the DOS command you need to put double quotes around the filename when the names havve spaces.
jdweng
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 6:14 PM -
Ah, I believe that is actually a named pipes connection. When you said you had a TCP/IP connection I thought you meant that you had a TcpListener running on the server and a TcpClient on the client that connected to the listener.
So you could go ahead and use the network share as the others have suggested if you don't mind configuring all of the file security required for each client.
Or you could add a TcpListener to the server application and have the client application use a TcpClient to open a connection to the server and pass the file data without worrying about windows file security.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 6:21 PM -
I forgot to mention in my last posting if you use a windows explorer all you have to do is type one of the following
\\mycomputername\
with admin account
\\mycomputername\c$ dollar sign indicates admion rights and c is the c drive
If you have permission you will simply see the folders that are shared. if permissions are not correct, then you will see a login popup.
jdweng
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 9:38 PM -
I forgot to mention in my last posting if you use a windows explorer all you have to do is type one of the following
\\mycomputername\
with admin account
\\mycomputername\c$ dollar sign indicates admion rights and c is the c drive
If you have permission you will simply see the folders that are shared. if permissions are not correct, then you will see a login popup.
jdweng
This could be acceptable if you have the server pull the files from the clients. Presumably the server is under an administrator's control and so it could be provided with domain admin credentials that allow it to access the administrative shares on the clients.
Whoops! I just reread one of the OP's old posts and they said "workgroup"... without a domain you wouldn't have a domain admin account with access to every client's administrative share (I'm not sure if administrative shares even exist in a workgroup).
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 9:58 PM -
I use the c$ all the time at work. You need admin rights on the computer that has the shared folder. You don't need the admin rights on the computer that you are running the Windows explorer If the credentials are setup properly the computer will automatically recognize you user account name.
jdweng
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 10:02 PM -
Are you on a Workgroup though Joel? Or an Active Directory domain?
I haven't use a workgroup since Windows 95, so I'm not sure what the limitations are. =P
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 10:05 PM -
I don't know how my MIS dept has the network configured. I just know there is a domain server that everytime you login the password is verified with the domain server no metter which computer you login to. I sometimes work on 10 different computers in one day. Often I copy files from one computer to another, or to/from a disk server.
jdweng
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 10:11 PM -
I don't know how my MIS dept has the network configured. I just know there is a domain server that everytime you login the password is verified with the domain server no metter which computer you login to. I sometimes work on 10 different computers in one day. Often I copy files from one computer to another, or to/from a disk server.
jdweng
Ok in that case you are on a full Active Directory domain, not a Workgroup.
I *think* the administrative shares as you describe them are only valid on a computer that is a member of a domain. I think you need explicitly defined shares within a workgroup... but like I said, it's been a LONG time since I had to use computers in a Workgroup and not in a Domain.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Monday, February 4, 2013 10:25 PM -
Thanks Joel,
I believe you understand my issue.
As I said, I have set up a server computer and one client computer and I have connected them with a simple Ethernet cable. I have setup both computers on the same workgroup.
The client is able to read/write on the server SQL Server Database through a regular SQL connection, as I explained earlier.
When I type \\ComputerName\ in Windows Explorer, I receive an error message. When I click on the "Network" node and click again on the server name, same message. It has to be a security issue !
What is the error message? Does the comptuer represented by "ComputerName" have any file shares defined? If it has a file share that the user has access to then that share should show up when you expand the computer in the network explorer.Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Monday, February 4, 2013 10:28 PM -
Thanks Reed,
The TcpListener solution might work... but I believe that a "simple" file copy ought to require much less effort and brain squeezing !! Amazing how a simple request ends up in several posts not adressing the issue itself... Does anyone really understand Windows security settings ?
Yes, I do understand them, that's why I suggest that you copy the file through your own socket so that you don't have to mess with user accounts. =P
Since you don't have an Active Directory domain, your networking capabilites are limited. A user account on one computer means nothing to another computer. You will have to create a user account on the local server and use that username and password when your other clients try to connect. Or you have to create a shared folder on the server that allows access from any user (unrestricted).
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Monday, February 4, 2013 10:32 PM -
Yes, Joel, I'm sure you are right. This is the ideal situation where computers are in the same domain.
Then, in that case, everything becomes easy....
In my case, the client computers are not real computers, they are more like POS terminals, the kind you find in restaurants, they use the terminals to take orders and print your check. There is no keyboard, you enter data directly on the terminal.
So I'm unsure whether it is possible to create a domain with userId and password...
Any chance that you could upload it to a website (FTP - if it has an HTTP component then make sure that it's not set for open browsing) then on the client end, use the method of a WebClient to read the text from that URL?
Other than passing the credentials needed - which you do in code - there are no other security restrictions.
Please call me Frank :)
- Proposed as answer by Reed KimbleMVP Wednesday, February 6, 2013 8:33 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Monday, February 4, 2013 10:34 PM -
Yes, Joel, I'm sure you are right. This is the ideal situation where computers are in the same domain.
Then, in that case, everything becomes easy....
In my case, the client computers are not real computers, they are more like POS terminals, the kind you find in restaurants, they use the terminals to take orders and print your check. There is no keyboard, you enter data directly on the terminal.
So I'm unsure whether it is possible to create a domain with userId and password...
If the clients run a form of windows that supports framework 4 (which I have to assume they do since we are talking about installing a .Net application on them) then they should be able to be a member of a domain.Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Monday, February 4, 2013 10:38 PM -
Pull the cable out and hold the RJ45 jacks together and see if the colors of the wires on the left RJ45 jack precisely match in order the colors of the right RJ45 Jack. If so it's not a crossover cable.
Personally, instead of removing the computers from the WIFI network where we KNEW they were working correctly I would turn off the ETHERNET connections and go back to WIFI. Then look at the servers WIFI address and use that for transmitting to and receiving on. After all no other computer is going to receive your data and you ARE NOT going to cause any disruption in the WIFI network.
Below is a picture of a straight through cable, see how the wires on the left RJ45 precisely match the wires on the right RJ45.
You've taught me everything I know but not everything you know.
- Edited by Mr. Monkeyboy Wednesday, February 6, 2013 5:18 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 5:04 PM -
You have to have the receive button pressed so the listener is already in receive mode before you hit the transmitters button or the transmitter will error out after a bit because nobody responded to its attempt to transmit.
The receiver should just sit their listening for in incoming transmission without timing out. But after the receiver receives one time it shuts off and you have to restart it before transmitting to it again. You could alter the code so it doesn't shut down though in this section I believe you could just comment out these two lines
tcpClient.Close() tcpListener.Stop()
but you probably would need to add a Form1 Me.OnClosing event to turn them off prior to exiting the application or it may crash for all I know. Like so.
Private Sub Form1_FormClosing(sender As Object, e As EventArgs) Handles Me.FormClosing tcpClient.Close() tcpListener.Stop() End Sub
You've taught me everything I know but not everything you know.
- Edited by Mr. Monkeyboy Wednesday, February 6, 2013 5:26 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 5:20 PM -
I have some recommendations for the now and the future:
1. as others suggested an Active directory domain is great (just install role and correct programs on windows server box and you can have a small server setup without much hassle). If you are using SQL server you can link usernames from the active directory database eliminating need to do them twice compared to a workgroup with proper settings. The server side needs a fixed ip address.
2. Go look at competitors POS products which usually are made to work on a domain such as lunchbox (http://www.lunchbox-k12.com/). We use it at our school system and it works on a domain which is where most POS machines will be especially at school and large organizations.
3. Workgroups and Wi-Fi are not useful in the long run because you will need big code overhauls to produce correct results as the environment changes (especially in large business's)
4. If you want to sell to public education sector you need infinite campus support (they use POS machines a lot).
5. use a $25-35 dollar Ethernet switch from fry's electronics, radio shack, or your local electronics store if you insist on using the multiple computers regardless of wheter you are on a workgroup or domain.
http://www.radioshack.com/product/index.jsp?productId=2894746
6. as far a logging into the computer you can have an on-screen keyboard appear for the user (yours or windows built in on-screen keyboard) but usually their is a backup hardware keyboard stored at most school cafeterias and fast food restaurants somewhere.
For the sql part you do not need to transfer text files or binary for that matter via a share you can transfer the text from the text files to sql server in a query. Just use SQL server management studio to help you form it.
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr
- Edited by The Thinker Wednesday, February 6, 2013 7:01 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 6:35 PM -
At this point I'm going to suggest that you go with Frank's idea because it will be the solution that requires the least amount of knowledge.
To be honest, I think you need to hire someone to help you.
If you could get to the point where your workgroup allowed you to use Explorer to view file shares, then you could get help from these forums on copying the files using VB.Net. But to get the networking going, you would need to use a Windows networking forum, or hire someone to come set it up for you.
Using your own socket and protocol to send the file is not overly complex, but it may be beyond beginner skill-level. You would have to be able to define a simple protocol for the file transfer as well as setup the async client connections and stream reading. I actually have a sample project on MSDN (the Samples link at the top of the page), but I suspect that adapting it to your purposes is beyond your current capabilities.
But if you can get an FTP site going on your server (which you should be able to do through the server's configuration wizard) then it is a short and sweet block of code to upload the file to the FTP server. A Windows Server forum on Technet would probably be able to help you get the FTP service setup if you needed assistance.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 8:41 PM -
At this point I'm going to suggest that you go with Frank's idea because it will be the solution that requires the least amount of knowledge.
To be honest, I think you need to hire someone to help you.
If you could get to the point where your workgroup allowed you to use Explorer to view file shares, then you could get help from these forums on copying the files using VB.Net. But to get the networking going, you would need to use a Windows networking forum, or hire someone to come set it up for you.
Using your own socket and protocol to send the file is not overly complex, but it may be beyond beginner skill-level. You would have to be able to define a simple protocol for the file transfer as well as setup the async client connections and stream reading. I actually have a sample project on MSDN (the Samples link at the top of the page), but I suspect that adapting it to your purposes is beyond your current capabilities.
But if you can get an FTP site going on your server (which you should be able to do through the server's configuration wizard) then it is a short and sweet block of code to upload the file to the FTP server. A Windows Server forum on Technet would probably be able to help you get the FTP service setup if you needed assistance.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
I agree that franks code is one option or their is the option of asking in a TechNet forum for helping on ad (active directory) network design (basic network setup in ad is not hard at all but you have the option of dynamically adding users or import from ad into your program allowing certain rights based on what rights the user has in ad) and going with joels option (most servers right out of the box allow you to create a shared folder).
Note: For both ways wheter ad or not just make sure the server always has a static ip address. In addition, you could just change permission on the folder to a specific user if need be (In a workgroup on a client machine just use your administrator username and password you created when you installed windows to connect to the share).
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr
- Edited by The Thinker Wednesday, February 6, 2013 9:03 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 8:47 PM -
Monkeyboy,
Now that I'm into this TCP file transfer project, I want to finish it !!
I finally managed to get a data transfer from one computer to another !! But not the other way around !!My cable definitely looks like a straight cable. So I unplugged it and went back to WiFi connections only.
Just to be sure, I added a third computer on this mini-network, did all sorts of tests and this is what I ended up with :
- all data transfers have ben successful, except the ones received by one single computer. In other words, everything is fine, except the receptions on one single computer (my main development machine). What could be the explanation ?? Thanks
1. It could be your development machine has a firewall blocking the TCP Receiver from connecting to the logical port on start up. My computer advises me, when I start the TCP Receiver, If I want to allow it access because I have not configured it into my firewall as an authorized application.
2. Are all three computers on the mini network using the same IP extended network portion of the address with the correct host portion according to the subnet mask? For example my subnet mask is 255.255.255.0, my network portion is 192.168.0. and my host portion can be from 1 to 254. Currently my WIFI cable modem (the default gateway) is assigned 192.168.0.1 on its WIFI interface and and it's DHCP server provided my computer with 192.168.0.13 when I logged onto the network. So what is the IP address of all three of your computers and the subnet mask of all three of them? Maybe they are on different WIFI networks?
3. There could be many other issues associated to this also but without being there I can't really guess as to the possibly nature of the problem.
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 9:54 PM
All replies
-
The first question you need to anser is if you want to make the file system on the computer shared. If you do the answer if simple becuase you can copy to the computer name like
\\computer abc\c\myfolder\abc.txt.
Depending on the access rights to the computer will depend if you can copy the files. If both computers use the same group policies then you should be able to copy the files. To enble sharing right click on the folder(s) you want to be shared and select properties from a window exploere.
If you don't want to make the file shared then you could use the class FTPWEbRequest to transfer files.
jdweng
- Marked as answer by Sygrien Thursday, February 7, 2013 3:29 PM
Monday, February 4, 2013 12:22 PM -
This looks pretty good and I'm sure the software could be made to use file system watcher to auto detect new files on the clients and transmit them to the server. Don't know how the code works or how it knows what to name files received from the clients. But it's TCP based. Any how it's at Code Project and looks like something you could use.
On the other hand if the systems are already networked together to allow sharing it seems that you could just use a file system watcher to monitor each clients folder then use one of the copy commands to copy a new file from a client to a specified server folder.
You've taught me everything I know but not everything you know.
- Edited by Mr. Monkeyboy Monday, February 4, 2013 12:48 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:29 PM
Monday, February 4, 2013 12:34 PM -
Heres an example of a, probably not well written, file system watcher watching the folder C:\Users\John\Desktop\Test1 and whenever a file is added to it the file is autocopied to C:\Users\John\Desktop\Test2 by the application.
Imports System.IO Imports System.Diagnostics Public Class Form1 Public watchfolder As FileSystemWatcher Dim FilePathFrom As String = "" Dim FilePathTo As String = "" Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Control.CheckForIllegalCrossThreadCalls = False txt_WatchPath.Text = "C:\Users\John\Desktop\Test1" End Sub Private Sub txt_WatchPath_TextChanged(sender As Object, e As EventArgs) Handles txt_WatchPath.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles txt_FolderActivity.TextChanged End Sub Private Sub btn_StartWatch_Click(sender As Object, e As EventArgs) Handles btn_StartWatch.Click watchfolder = New System.IO.FileSystemWatcher() watchfolder.Path = txt_WatchPath.Text watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.FileName watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.Attributes AddHandler watchfolder.Changed, AddressOf logchange AddHandler watchfolder.Created, AddressOf logchange AddHandler watchfolder.Deleted, AddressOf logchange AddHandler watchfolder.Renamed, AddressOf logrename watchfolder.EnableRaisingEvents = True btn_StartWatch.Enabled = False btn_Stop.Enabled = True End Sub Private Sub logchange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs) If e.ChangeType = IO.WatcherChangeTypes.Changed Then txt_FolderActivity.Text &= "File " & e.FullPath & " has been modified" & vbCrLf End If If e.ChangeType = IO.WatcherChangeTypes.Changed Then Me.Text = FileLen(e.FullPath) End If If e.ChangeType = IO.WatcherChangeTypes.Created Then txt_FolderActivity.Text &= "File " & e.FullPath & " has been created" & vbCrLf Dim Test As String = e.FullPath.ToString() Test = Test.Remove(26, 1) Test = Test.Insert(26, "2") FilePathFrom = e.FullPath.ToString() FilePathTo = Test CopyingFile() End If If e.ChangeType = IO.WatcherChangeTypes.Deleted Then txt_FolderActivity.Text &= "File " & e.FullPath & " has been deleted" & vbCrLf End If End Sub Public Sub logrename(ByVal source As Object, ByVal e As System.IO.RenamedEventArgs) txt_FolderActivity.Text &= "File" & e.OldName & " has been renamed to " & e.Name & vbCrLf End Sub Private Sub btn_Stop_Click(sender As Object, e As EventArgs) Handles btn_Stop.Click watchfolder.EnableRaisingEvents = False btn_StartWatch.Enabled = True btn_Stop.Enabled = False End Sub Private Sub CopyingFile() btn_Stop.PerformClick() FileCopy(FilePathFrom, FilePathTo) txt_FolderActivity.Text &= "File " & FilePathFrom & " Copied to " & FilePathTo & vbCrLf btn_StartWatch.PerformClick() End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub End Class
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:29 PM
Monday, February 4, 2013 1:51 PM -
Thank you Joel for this reply.
Can you please elaborate on the "group policies" that need to be the same on both computers ...
I have setup the server computer and one of the client computers to be in the same WorkGroup. That is, I have entered the same workgroup name on both computers. Is that what you describe ?
Also I have created a shared directory.
I have tried to simply do a DOS copy (on the Command Prompt) but it failed with this error message :
"Logon failure : unknown user name or bad password".
Monday, February 4, 2013 5:00 PM -
Is it your application that has created the TCP/IP connection between the client(s) and the server?
If so, you already have a connection so why not use it? Just have the clients pass the file data over the current connection. Depending on how you use the connection you might have to extend your protocol to indicate what kind of transfer is occuring.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 5:01 PM -
Thank you Mr Monkeyboy for this reply.
My problem is my vast ignorance about security settings, file sharing and file copying between computers. I'm simply unable to copy one file to another computer.
Monday, February 4, 2013 5:03 PM -
Thank you Mr MonkeyBoy for this piece of code.
I think your code copies files on the same computer. My problem is to copy files from one computer to another.
My questions are :
1) Do I need to create shared directories ?
2) Do I need to set the two computers on the same WorkGroup ? On the same domain ?
3) Do I need to create a specific userID and password on the receiving computer ?
4) Can I use an IP address in a File.Copy command ?
5) Do I need to specify a userID and a password in the File.Copy command ? How ?
Monday, February 4, 2013 5:08 PM -
Thank you Reed,
Yes, that is a good idea !
The connection between the clients and the server is a regular SQL server connection. I use a ConnectionString with typical parameters :
Data Source=\\ServerName,Initial Catalog=DatabaseName,UserID=xxx,Password=xxx
So you are saying I can also send a text file in this way ??
Monday, February 4, 2013 5:16 PM -
Thank you Mr MonkeyBoy for this piece of code.
I think your code copies files on the same computer. My problem is to copy files from one computer to another.
My questions are :
1) Do I need to create shared directories ?
2) Do I need to set the two computers on the same WorkGroup ? On the same domain ?
3) Do I need to create a specific userID and password on the receiving computer ?
4) Can I use an IP address in a File.Copy command ?
5) Do I need to specify a userID and a password in the File.Copy command ? How ?
That code I displayed copies a file at a time and would need to be altered to be of any real value.
1) I've been out of this type of networking for sometime and am unsure what the best scenario for you is.
2) as a test you can set the two computers in the same workgroup with file sharing allowed. This may not be a good route as far as security in a real world environment though. Don't know about the domain issue. That software I displayed can copy files on a workgroup from one computer to another if filesharing is established.
3) Don't know.
4) Don't think so but with that TCP software link I provided that would be unecessary AFAIK.
5) Don't know.
Since this is a VB.Net forum and not a Microsoft Windows Networking forum I recommend further research for you.
"Microsoft Windows is the most installed desktop operating system on the planet. In this section, you will learn Windows tips and tricks, networking how-tos, system administration, software development, data recovery, and more. "
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 5:32 PM -
I would first try copying the file using a window explorer before trying with DOS (cms.exe). with cmd.exe there are sometimes issues with file name when they have spaces. In the DOS command you need to put double quotes around the filename when the names havve spaces.
jdweng
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 6:14 PM -
Ah, I believe that is actually a named pipes connection. When you said you had a TCP/IP connection I thought you meant that you had a TcpListener running on the server and a TcpClient on the client that connected to the listener.
So you could go ahead and use the network share as the others have suggested if you don't mind configuring all of the file security required for each client.
Or you could add a TcpListener to the server application and have the client application use a TcpClient to open a connection to the server and pass the file data without worrying about windows file security.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 6:21 PM -
I forgot to mention in my last posting if you use a windows explorer all you have to do is type one of the following
\\mycomputername\
with admin account
\\mycomputername\c$ dollar sign indicates admion rights and c is the c drive
If you have permission you will simply see the folders that are shared. if permissions are not correct, then you will see a login popup.
jdweng
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 9:38 PM -
I forgot to mention in my last posting if you use a windows explorer all you have to do is type one of the following
\\mycomputername\
with admin account
\\mycomputername\c$ dollar sign indicates admion rights and c is the c drive
If you have permission you will simply see the folders that are shared. if permissions are not correct, then you will see a login popup.
jdweng
This could be acceptable if you have the server pull the files from the clients. Presumably the server is under an administrator's control and so it could be provided with domain admin credentials that allow it to access the administrative shares on the clients.
Whoops! I just reread one of the OP's old posts and they said "workgroup"... without a domain you wouldn't have a domain admin account with access to every client's administrative share (I'm not sure if administrative shares even exist in a workgroup).
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 9:58 PM -
I use the c$ all the time at work. You need admin rights on the computer that has the shared folder. You don't need the admin rights on the computer that you are running the Windows explorer If the credentials are setup properly the computer will automatically recognize you user account name.
jdweng
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 10:02 PM -
Are you on a Workgroup though Joel? Or an Active Directory domain?
I haven't use a workgroup since Windows 95, so I'm not sure what the limitations are. =P
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 10:05 PM -
I don't know how my MIS dept has the network configured. I just know there is a domain server that everytime you login the password is verified with the domain server no metter which computer you login to. I sometimes work on 10 different computers in one day. Often I copy files from one computer to another, or to/from a disk server.
jdweng
- Marked as answer by Sygrien Thursday, February 7, 2013 3:30 PM
Monday, February 4, 2013 10:11 PM -
Thanks Joel,
I believe you understand my issue.
As I said, I have set up a server computer and one client computer and I have connected them with a simple Ethernet cable. I have setup both computers on the same workgroup.
The client is able to read/write on the server SQL Server Database through a regular SQL connection, as I explained earlier.
When I type \\ComputerName\ in Windows Explorer, I receive an error message. When I click on the "Network" node and click again on the server name, same message. It has to be a security issue !
Monday, February 4, 2013 10:20 PM -
Thanks Reed,
The TcpListener solution might work... but I believe that a "simple" file copy ought to require much less effort and brain squeezing !! Amazing how a simple request ends up in several posts not adressing the issue itself... Does anyone really understand Windows security settings ?
Monday, February 4, 2013 10:23 PM -
I don't know how my MIS dept has the network configured. I just know there is a domain server that everytime you login the password is verified with the domain server no metter which computer you login to. I sometimes work on 10 different computers in one day. Often I copy files from one computer to another, or to/from a disk server.
jdweng
Ok in that case you are on a full Active Directory domain, not a Workgroup.
I *think* the administrative shares as you describe them are only valid on a computer that is a member of a domain. I think you need explicitly defined shares within a workgroup... but like I said, it's been a LONG time since I had to use computers in a Workgroup and not in a Domain.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Monday, February 4, 2013 10:25 PM -
Thanks Joel,
I believe you understand my issue.
As I said, I have set up a server computer and one client computer and I have connected them with a simple Ethernet cable. I have setup both computers on the same workgroup.
The client is able to read/write on the server SQL Server Database through a regular SQL connection, as I explained earlier.
When I type \\ComputerName\ in Windows Explorer, I receive an error message. When I click on the "Network" node and click again on the server name, same message. It has to be a security issue !
What is the error message? Does the comptuer represented by "ComputerName" have any file shares defined? If it has a file share that the user has access to then that share should show up when you expand the computer in the network explorer.Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Monday, February 4, 2013 10:28 PM -
Yes, Joel, I'm sure you are right. This is the ideal situation where computers are in the same domain.
Then, in that case, everything becomes easy....
In my case, the client computers are not real computers, they are more like POS terminals, the kind you find in restaurants, they use the terminals to take orders and print your check. There is no keyboard, you enter data directly on the terminal.
So I'm unsure whether it is possible to create a domain with userId and password...
Monday, February 4, 2013 10:30 PM -
Thanks Reed,
The TcpListener solution might work... but I believe that a "simple" file copy ought to require much less effort and brain squeezing !! Amazing how a simple request ends up in several posts not adressing the issue itself... Does anyone really understand Windows security settings ?
Yes, I do understand them, that's why I suggest that you copy the file through your own socket so that you don't have to mess with user accounts. =P
Since you don't have an Active Directory domain, your networking capabilites are limited. A user account on one computer means nothing to another computer. You will have to create a user account on the local server and use that username and password when your other clients try to connect. Or you have to create a shared folder on the server that allows access from any user (unrestricted).
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Monday, February 4, 2013 10:32 PM -
Yes, Joel, I'm sure you are right. This is the ideal situation where computers are in the same domain.
Then, in that case, everything becomes easy....
In my case, the client computers are not real computers, they are more like POS terminals, the kind you find in restaurants, they use the terminals to take orders and print your check. There is no keyboard, you enter data directly on the terminal.
So I'm unsure whether it is possible to create a domain with userId and password...
Any chance that you could upload it to a website (FTP - if it has an HTTP component then make sure that it's not set for open browsing) then on the client end, use the method of a WebClient to read the text from that URL?
Other than passing the credentials needed - which you do in code - there are no other security restrictions.
Please call me Frank :)
- Proposed as answer by Reed KimbleMVP Wednesday, February 6, 2013 8:33 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Monday, February 4, 2013 10:34 PM -
Yes, Joel, I'm sure you are right. This is the ideal situation where computers are in the same domain.
Then, in that case, everything becomes easy....
In my case, the client computers are not real computers, they are more like POS terminals, the kind you find in restaurants, they use the terminals to take orders and print your check. There is no keyboard, you enter data directly on the terminal.
So I'm unsure whether it is possible to create a domain with userId and password...
If the clients run a form of windows that supports framework 4 (which I have to assume they do since we are talking about installing a .Net application on them) then they should be able to be a member of a domain.Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Monday, February 4, 2013 10:38 PM -
Thanks Reed, I think you spotted the issue. I have setup a workgroup because it brings less constraints. But will it work ??Tuesday, February 5, 2013 7:20 AM
-
For testing purposes, I have setup shared directories on both computers (the server and the client). On both computers, when I expand the other computer in the network explorer, I get the same error message ("Windows cannot access xxxx( computer name)").
But again, this is only a workgroup setting.
Tuesday, February 5, 2013 7:26 AM -
Reed,
This is a reply to your suggestion of using "my own socket". I do not understand this. Is it another communication protocol ? Can I do this in code ?
Also, when you say I can create a user account on the server and use it when connecting, how is this possible ? When trying to connect from a client, I only receive the same error message, with no chance of entering a userid and password. And, if I could, how would I pass those credentials in code ?
Thanks
Tuesday, February 5, 2013 7:32 AM -
Hello Franck, thanks for your suggestion.
Yes, I believe that would be possible. But I see this as a workaround. I'd like to explore "simple" possibilities first.
Also, in the category of workarounds, I could write the info from the client to the database on the server. Then develop a service on the server to read that info.
Tuesday, February 5, 2013 7:38 AM -
If the clients run a form of windows that supports framework 4 (which I have to assume they do since we are talking about installing a .Net application on them) then they should be able to be a member of a domain.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
Yes, Reed, as this threads develops, I have the feeling there is no way around setting up a domain...
Do you know if I can automate this ? See, I have 30 client terminals. How may I set up the domain ? Should I use a different ID for each terminal ? How would each client terminal be configured ? Is it possible to have a blank password on the terminal ? (If the client terminal shuts down, the user won't be able to start it, if a password is required).
Thanks
Tuesday, February 5, 2013 7:45 AM -
Or you could add a TcpListener to the server application and have the client application use a TcpClient to open a connection to the server and pass the file data without worrying about windows file security.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
Reed,
I have never used this ... How does this work ? Do you have, by chance, a code example ?
How would then security issues be addressed ? (I'm sure the communication has to go through some kind of credentials verification ?).
Thanks
Tuesday, February 5, 2013 7:51 AM -
Reed,I have never used this ... How does this work ? Do you have, by chance, a code example ?
How would then security issues be addressed ? (I'm sure the communication has to go through some kind of credentials verification ?).
Thanks
Dude I gave you a link to a TCP Server/Client program Here so you can read up on how it works. But it's probably designed for manual addition of files to the client for sending to the server or vice versa I'm fairly certain.
No credentials would be required.
But you would probably have to alter the code so that a file system watcher could automatically pass files to the clients application for transmission to the server whenever the clients user placed a file in a certain folder.
If you want I can post a TCP Transmitter and TCP Receiver for you that you can test between two computers (as long as you know their addresses) and send basic text from the TCP Transmitter to the TCP receiver. Very small applications and easy to copy/paste into a couple of seperate WinForm apps. Which will show you that no credentials are required.
On the other hand my computers firewall doesn't realize the my TCP receiver is an authorized application so it always trys to block it on start up but asks me if I want to allow the TCP receiver to have access. This of course can be alleviated by adding the TCP receiver as an authorized application in the firewall which I haven't done.
But no "credentials" are necessary to use either one.
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Tuesday, February 5, 2013 8:09 AM -
Or you could add a TcpListener to the server application and have the client application use a TcpClient to open a connection to the server and pass the file data without worrying about windows file security.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
Reed,
I have never used this ... How does this work ? Do you have, by chance, a code example ?
How would then security issues be addressed ? (I'm sure the communication has to go through some kind of credentials verification ?).
Thanks
Here's what the TCP transmitter and TCP receiver look like in operation. Although the transmitter sends data to the receiver with no problem the data never goes out onto the network in my instance because it loops back in an IP stack layer before ever departing my machine since both applications are using my same physical IP address.
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Tuesday, February 5, 2013 8:21 AM -
Here's a TCP Transmitter and a TCP Receiver.
Note in the Images for each that the first two boxes are textboxes and the second two are richtextboxes on each form. Labels should be self explanatory. Buttons too.
Also the IP address can just be typed over with a new IP address prior to transmission or reception. So the transmitter would have the IP address of the computer it is on and the receiver would have the IP address of the computer it is on. The transmitter needs to transmit on the same logical port that the receiver is listening on. You can use logical port 8004 as it is unassigned for any particular use instead of logical port 8000 which I hard coded and is supposed to be used for some non descript app.
First Code Block is transmitter.
Imports System.Net.Sockets Imports System.Text Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load TextBox1.Text = "192.168.0.13" TextBox2.Text = "8000" End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim tcpClient As New System.Net.Sockets.TcpClient() Try tcpClient.Connect(TextBox1.Text, TextBox2.Text) Dim networkStream As NetworkStream = tcpClient.GetStream() If networkStream.CanWrite And networkStream.CanRead Then Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(RichTextBox2.Text) networkStream.Write(sendBytes, 0, sendBytes.Length) Dim bytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) Dim returndata As String = Encoding.ASCII.GetString(bytes) RichTextBox1.AppendText("Host returned: " & returndata & vbCrLf) Else If Not networkStream.CanRead Then RichTextBox1.AppendText("cannot not write data to this stream" & vbCrLf) tcpClient.Close() Else If Not networkStream.CanWrite Then RichTextBox1.AppendText("cannot read data from this stream" & vbCrLf) tcpClient.Close() End If End If End If Catch ex As Exception RichTextBox1.AppendText(ex.Message & vbCrLf) End Try End Sub Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged End Sub Private Sub RichTextBox2_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox2.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click End Sub Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click End Sub End Class
Now the receiver
Imports System.Net.Sockets Imports System.Text Imports System.Net Public Class Form1 'http://www.eggheadcafe.com/articles/20020323.asp Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load TextBox1.Text = "192.168.0.13" TextBox2.Text = "8000" End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Dim ipAddress As IPAddress = ipAddress.Parse(TextBox1.Text) Dim portNumber As Integer = TextBox2.Text Dim tcpListener As New TcpListener(ipAddress, portNumber) tcpListener.Start() RichTextBox1.AppendText("Waiting for connection..." & vbCrLf) Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient() RichTextBox1.AppendText("Connection accepted." & vbCrLf) Dim networkStream As NetworkStream = tcpClient.GetStream() Dim bytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) Dim clientdata As String = Encoding.ASCII.GetString(bytes) RichTextBox2.AppendText("Client sent: " & clientdata & vbCrLf) Dim responseString As String = "Connected to server." Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString) networkStream.Write(sendBytes, 0, sendBytes.Length) RichTextBox1.AppendText(vbCrLf & "Message Sent /> : " & responseString) tcpClient.Close() tcpListener.Stop() RichTextBox1.AppendText("exit") Catch ex As Exception RichTextBox1.AppendText(ex.Message) End Try End Sub Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged End Sub Private Sub RichTextBox2_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox2.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click End Sub Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click End Sub End Class
Now the Images so you can create similiar Forms for each
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:31 PM
Tuesday, February 5, 2013 8:48 AM -
Mr MonkeyBoy,
Thanks, thanks and thanks again !
Please allow me some time to read, understand and copy all this.
Will be back !!
Tuesday, February 5, 2013 6:21 PM -
Mr MonkeyBoy,
Thanks, thanks and thanks again !
Please allow me some time to read, understand and copy all this.
Will be back !!
I did a change up on you. Now I made the TCP Transmitter and TCP Receiver to transmit and receive files. I transmitted and received a .txt file, a .wmv file and a .exe file (Notepad) to verify no problems with the received files.
First is the TCP Transmitter code, then the TCP Receiver code and finally the Images.
Imports System.Net.Sockets Imports System.Text Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load TextBox1.Text = "192.168.0.13" TextBox2.Text = "8004" End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim tcpClient As New System.Net.Sockets.TcpClient() Try tcpClient.Connect(TextBox1.Text, TextBox2.Text) Dim networkStream As NetworkStream = tcpClient.GetStream() If networkStream.CanWrite And networkStream.CanRead Then Dim TXFileSize As String TXFileSize = CStr(FileLen(TextBox3.Text)) Dim SendTXFileSize As [Byte]() = Encoding.ASCII.GetBytes(TXFileSize) networkStream.Write(SendTXFileSize, 0, SendTXFileSize.Length) Dim TXBytes() As Byte TXBytes = My.Computer.FileSystem.ReadAllBytes(TextBox3.Text) networkStream.Write(TXBytes, 0, TXBytes.Length) Dim RXbytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(RXbytes, 0, CInt(tcpClient.ReceiveBufferSize)) Dim returndata As String = Encoding.ASCII.GetString(RXbytes) RichTextBox1.AppendText("Host returned: " & returndata & vbCrLf) Else If Not networkStream.CanRead Then RichTextBox1.AppendText("cannot not write data to this stream" & vbCrLf) tcpClient.Close() Else If Not networkStream.CanWrite Then RichTextBox1.AppendText("cannot read data from this stream" & vbCrLf) tcpClient.Close() End If End If End If Catch ex As Exception RichTextBox1.AppendText(ex.Message & vbCrLf) End Try End Sub Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged End Sub Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click End Sub Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click End Sub End Class
Imports System.Net.Sockets Imports System.Text Imports System.Net Public Class Form1 'http://www.eggheadcafe.com/articles/20020323.asp Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load TextBox1.Text = "192.168.0.13" TextBox2.Text = "8004" TextBox3.Text = "C:\Users\John\Desktop\Test.wmv" End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Try Dim ipAddress As IPAddress = ipAddress.Parse(TextBox1.Text) Dim portNumber As Integer = TextBox2.Text Dim tcpListener As New TcpListener(ipAddress, portNumber) tcpListener.Start() RichTextBox1.AppendText("Waiting for connection..." & vbCrLf) Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient() RichTextBox1.AppendText("Connection accepted." & vbCrLf) Dim FileSize As NetworkStream = tcpClient.GetStream() Dim bytes(tcpClient.ReceiveBufferSize) As Byte FileSize.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) Dim clientdata As String = Encoding.ASCII.GetString(bytes) clientdata = CStr(CInt(clientdata) - 1) Dim File As NetworkStream = tcpClient.GetStream() Dim FileLength(CInt(clientdata)) As Byte File.Read(FileLength, 0, CInt(clientdata)) 'this worked for pegasus.wmv My.Computer.FileSystem.WriteAllBytes(TextBox3.Text, FileLength, False) Dim responseString As String = "Connected to server." Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(responseString) File.Write(sendBytes, 0, sendBytes.Length) RichTextBox1.AppendText(vbCrLf & "Message Sent /> : " & responseString) tcpClient.Close() tcpListener.Stop() RichTextBox1.AppendText("exit") Catch ex As Exception RichTextBox1.AppendText(ex.Message) End Try End Sub Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged End Sub Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged End Sub Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged End Sub Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click End Sub Private Sub Label2_Click(sender As Object, e As EventArgs) Handles Label2.Click End Sub Private Sub Label3_Click(sender As Object, e As EventArgs) Handles Label3.Click End Sub Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click End Sub End Class
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Tuesday, February 5, 2013 11:33 PM -
Hello MonkeyBoy !
I have copied and run your program.... with mixed results.I have two computers. I connect them with an Ethernet cable. I shut down WiFi networking on both computers, to avoid addressing confusion... I ping one computer from the other and I get responses OK.
On the "Server" computer, I run the Receiving (TcpListener) program. I set the IP Address to the server address.
On the "Client" computer, I run the Transmitting (TcpClient) program. I set the IP Address to the server address. So both forms show the same address and port number (8000).When I hit the "Receive" button on the Server computer, the form freezes, and I get the wait cursor, which I think is a good sign because your code uses only Synchronized methods. So I guess the server is waiting for a connection.
When I hit the "Transmit" button on the Client computer, the program waits for a while, then I receive an error message "A connection attempt has failed because the receiving party has not responded....". On the Server computer, nothing happened, still freezing.
What could be wrong ? Thanks
Wednesday, February 6, 2013 2:57 PM -
First of all you can not connect two computers with a standard ethernet cable. You have to have either an ethernet crossover cable or connect both computers to a minihub which acts as a bridge. So I don't know how you're able to ping each computer. Also the program will not freeze while in receive mode or transmit mode except during transmission of really large data like my 122MB .Wav file but the transmission and reception only takes a couple of seconds anyhow.
Also you have to configure the IP stacks of each computer with the correct IP address of the computer and the correct subnet mask. And the correct IP stack layers to support hardcoded IP address/subnet mask/non-DHCP, etc which I don't know how to do on my Win7 laptop cause I never had a reason to try.
Below is the pinout for an RJ-45 jack for an ethernet crossover cable.
1tx+ to +rx3
2tx- to -rx7
3rx+ to +tx1
7rx- to -tx2
You've taught me everything I know but not everything you know.
- Edited by Mr. Monkeyboy Wednesday, February 6, 2013 4:52 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 4:32 PM -
I don't know how, but I can see the computers are talking to one another, through a direct Ethernet cable. One is running Vista, the other is running Windows7. When I open the Network and Sharing center, I can see there is a Local Area Connection. When I click the connection, I can see its status, with the number of bytes sent and received, and this number evolves. Maybe it is a crossover cable...
Anyway, this is not the issue. Still trying to send and receive through TCPClient and TCPListener !
Wednesday, February 6, 2013 4:56 PM -
Pull the cable out and hold the RJ45 jacks together and see if the colors of the wires on the left RJ45 jack precisely match in order the colors of the right RJ45 Jack. If so it's not a crossover cable.
Personally, instead of removing the computers from the WIFI network where we KNEW they were working correctly I would turn off the ETHERNET connections and go back to WIFI. Then look at the servers WIFI address and use that for transmitting to and receiving on. After all no other computer is going to receive your data and you ARE NOT going to cause any disruption in the WIFI network.
Below is a picture of a straight through cable, see how the wires on the left RJ45 precisely match the wires on the right RJ45.
You've taught me everything I know but not everything you know.
- Edited by Mr. Monkeyboy Wednesday, February 6, 2013 5:18 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 5:04 PM -
Thanks for the idea.... will try it.
Question : should I first press the "Send" button on computer 1 or first the "Receive" button on computer 2 ? Or does it not matter ? And how much time do I have to perform both operations ?
Wednesday, February 6, 2013 5:16 PM -
You have to have the receive button pressed so the listener is already in receive mode before you hit the transmitters button or the transmitter will error out after a bit because nobody responded to its attempt to transmit.
The receiver should just sit their listening for in incoming transmission without timing out. But after the receiver receives one time it shuts off and you have to restart it before transmitting to it again. You could alter the code so it doesn't shut down though in this section I believe you could just comment out these two lines
tcpClient.Close() tcpListener.Stop()
but you probably would need to add a Form1 Me.OnClosing event to turn them off prior to exiting the application or it may crash for all I know. Like so.
Private Sub Form1_FormClosing(sender As Object, e As EventArgs) Handles Me.FormClosing tcpClient.Close() tcpListener.Stop() End Sub
You've taught me everything I know but not everything you know.
- Edited by Mr. Monkeyboy Wednesday, February 6, 2013 5:26 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 5:20 PM -
I have some recommendations for the now and the future:
1. as others suggested an Active directory domain is great (just install role and correct programs on windows server box and you can have a small server setup without much hassle). If you are using SQL server you can link usernames from the active directory database eliminating need to do them twice compared to a workgroup with proper settings. The server side needs a fixed ip address.
2. Go look at competitors POS products which usually are made to work on a domain such as lunchbox (http://www.lunchbox-k12.com/). We use it at our school system and it works on a domain which is where most POS machines will be especially at school and large organizations.
3. Workgroups and Wi-Fi are not useful in the long run because you will need big code overhauls to produce correct results as the environment changes (especially in large business's)
4. If you want to sell to public education sector you need infinite campus support (they use POS machines a lot).
5. use a $25-35 dollar Ethernet switch from fry's electronics, radio shack, or your local electronics store if you insist on using the multiple computers regardless of wheter you are on a workgroup or domain.
http://www.radioshack.com/product/index.jsp?productId=2894746
6. as far a logging into the computer you can have an on-screen keyboard appear for the user (yours or windows built in on-screen keyboard) but usually their is a backup hardware keyboard stored at most school cafeterias and fast food restaurants somewhere.
For the sql part you do not need to transfer text files or binary for that matter via a share you can transfer the text from the text files to sql server in a query. Just use SQL server management studio to help you form it.
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr
- Edited by The Thinker Wednesday, February 6, 2013 7:01 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 6:35 PM -
Thanks The Tinker ! Great suggestions ! I will go for the domain approach.Wednesday, February 6, 2013 7:02 PM
-
Monkeyboy,
Now that I'm into this TCP file transfer project, I want to finish it !!
I finally managed to get a data transfer from one computer to another !! But not the other way around !!My cable definitely looks like a straight cable. So I unplugged it and went back to WiFi connections only.
Just to be sure, I added a third computer on this mini-network, did all sorts of tests and this is what I ended up with :
- all data transfers have ben successful, except the ones received by one single computer. In other words, everything is fine, except the receptions on one single computer (my main development machine). What could be the explanation ?? Thanks
Wednesday, February 6, 2013 7:09 PM -
Sygrien, when you get done send me the source because I work in the k-12 sector on computers in a IT department but my focus is mostly coding software/scripts with some hardware in-between from time to time. I can help you link it up with infinite campus. I have done many NDA beta tests on software/games too so I can keep a secret. We just upgraded our POS machines to windows 7 so its a great time to test drive something new. my work email is jeffery.carlson@garrard.kyschools.us
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr
- Edited by The Thinker Wednesday, February 6, 2013 7:34 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 7:28 PM -
At this point I'm going to suggest that you go with Frank's idea because it will be the solution that requires the least amount of knowledge.
To be honest, I think you need to hire someone to help you.
If you could get to the point where your workgroup allowed you to use Explorer to view file shares, then you could get help from these forums on copying the files using VB.Net. But to get the networking going, you would need to use a Windows networking forum, or hire someone to come set it up for you.
Using your own socket and protocol to send the file is not overly complex, but it may be beyond beginner skill-level. You would have to be able to define a simple protocol for the file transfer as well as setup the async client connections and stream reading. I actually have a sample project on MSDN (the Samples link at the top of the page), but I suspect that adapting it to your purposes is beyond your current capabilities.
But if you can get an FTP site going on your server (which you should be able to do through the server's configuration wizard) then it is a short and sweet block of code to upload the file to the FTP server. A Windows Server forum on Technet would probably be able to help you get the FTP service setup if you needed assistance.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 8:41 PM -
At this point I'm going to suggest that you go with Frank's idea because it will be the solution that requires the least amount of knowledge.
To be honest, I think you need to hire someone to help you.
If you could get to the point where your workgroup allowed you to use Explorer to view file shares, then you could get help from these forums on copying the files using VB.Net. But to get the networking going, you would need to use a Windows networking forum, or hire someone to come set it up for you.
Using your own socket and protocol to send the file is not overly complex, but it may be beyond beginner skill-level. You would have to be able to define a simple protocol for the file transfer as well as setup the async client connections and stream reading. I actually have a sample project on MSDN (the Samples link at the top of the page), but I suspect that adapting it to your purposes is beyond your current capabilities.
But if you can get an FTP site going on your server (which you should be able to do through the server's configuration wizard) then it is a short and sweet block of code to upload the file to the FTP server. A Windows Server forum on Technet would probably be able to help you get the FTP service setup if you needed assistance.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
I agree that franks code is one option or their is the option of asking in a TechNet forum for helping on ad (active directory) network design (basic network setup in ad is not hard at all but you have the option of dynamically adding users or import from ad into your program allowing certain rights based on what rights the user has in ad) and going with joels option (most servers right out of the box allow you to create a shared folder).
Note: For both ways wheter ad or not just make sure the server always has a static ip address. In addition, you could just change permission on the folder to a specific user if need be (In a workgroup on a client machine just use your administrator username and password you created when you installed windows to connect to the share).
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr
- Edited by The Thinker Wednesday, February 6, 2013 9:03 PM
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 8:47 PM -
Monkeyboy,
Now that I'm into this TCP file transfer project, I want to finish it !!
I finally managed to get a data transfer from one computer to another !! But not the other way around !!My cable definitely looks like a straight cable. So I unplugged it and went back to WiFi connections only.
Just to be sure, I added a third computer on this mini-network, did all sorts of tests and this is what I ended up with :
- all data transfers have ben successful, except the ones received by one single computer. In other words, everything is fine, except the receptions on one single computer (my main development machine). What could be the explanation ?? Thanks
1. It could be your development machine has a firewall blocking the TCP Receiver from connecting to the logical port on start up. My computer advises me, when I start the TCP Receiver, If I want to allow it access because I have not configured it into my firewall as an authorized application.
2. Are all three computers on the mini network using the same IP extended network portion of the address with the correct host portion according to the subnet mask? For example my subnet mask is 255.255.255.0, my network portion is 192.168.0. and my host portion can be from 1 to 254. Currently my WIFI cable modem (the default gateway) is assigned 192.168.0.1 on its WIFI interface and and it's DHCP server provided my computer with 192.168.0.13 when I logged onto the network. So what is the IP address of all three of your computers and the subnet mask of all three of them? Maybe they are on different WIFI networks?
3. There could be many other issues associated to this also but without being there I can't really guess as to the possibly nature of the problem.
You've taught me everything I know but not everything you know.
- Marked as answer by Sygrien Thursday, February 7, 2013 3:32 PM
Wednesday, February 6, 2013 9:54 PM -
My main issue, when I started this endless post was :
I will be implementing new terminals in plants, used by machine operators. They are keyboardless terminals, runnning Windows 7. The terminals will be used for one application only. As a matter of fact, terminals should never be shut off and the operator should not be able to exit the application... Except when power goes down or something similar… Therefore, it seems difficult to set the terminals with userids, passwords etc… So my first gut feeling was towards simple network workgroup settings. But I need to copy files from each terminal to the server, on a regular basis. That’s why I posted my question.
This has driven me far from my original issue, but I learned something about sending data using IP connections. So it is not a waste of my time.
I have not received a clear answer to my question. Probably because there is no simple one. But I have received many good ideas and opinions about my issue. Thank you to all.
Special Thanks to MonkeyBoy who shared code and cable diagrams !
Thanks to Joel for pointing out that my issues would diseappear in a domain context.
Thanks to Reed, who believes I am a beginner.
Thanks to TheThinker for his ideas. I have sent you some code on your email address.
Thanks to Franck for his idea about an FTP site, even if I'm not convinced it can be implemented at my customers.
Thursday, February 7, 2013 3:29 PM -
I forgot to mention their is a registry hack that causes a user to be logged on automatically every time the computer is started here (that way you just need a generic active directory or regular username for the machines the operators use):
http://www.computerperformance.co.uk/windows7/windows7_auto_logon.htm
Note: not to be used outside of your purpose on computers.
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr
- Edited by The Thinker Thursday, February 7, 2013 4:08 PM
Thursday, February 7, 2013 4:07 PM -
Why not just use a archive program that runs at night from the server that pulls the data.
jdweng
Thursday, February 7, 2013 4:43 PM -
Thanks for marking everybody as answers but I don't get what you intend to do now.
"I will be implementing new terminals in plants, used by machine operators. They are keyboardless terminals, runnning Windows 7."
I mean if that's the case I would try to get in on the ground level with the various plant IT departments to coordinate an effort at networking each of these terminals and the server into a Workgroup which should be no real effort if it's designed into the installation ahead of time.
After all if they already have the server and a LAN they can add the new workstations onto the LAN or they can add a new NIC to server in order to incorporate a seperate LAN for the new workstations.
The IT staff can then configure each workstation as part of the workgrou and to share files as the workstations are installed.
Then you could just use filewatchers on all of the workstations to copy files to the server as files are added to a folder on the workstations.
I would force this issue ahead of time and that way you don't find that one plant connects the worstations one way and another does it another way according to each plants IT staff.
You've taught me everything I know but not everything you know.
Thursday, February 7, 2013 5:28 PM -
The proper way to handle all of this (automatic logon, end user security, kisok functionality, server security, etc.) is through Group Policy settings, which I believe was already mentioned earlier.
However, correctly configuring Group Policy is not something to be taken lightly. I would highly suggest involving an AD engineer.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
Thursday, February 7, 2013 5:28 PM -
The proper way to handle all of this (automatic logon, end user security, kisok functionality, server security, etc.) is through Group Policy settings, which I believe was already mentioned earlier.
However, correctly configuring Group Policy is not something to be taken lightly. I would highly suggest involving an AD engineer.
Reed Kimble - "When you do things right, people won't be sure you've done anything at all"
Yes, I know their is also a group policy setting for my recommendation above but it is only for use on his terminal situation (he could also use smart cards so that he can figure out which employee logged on at what time without using that approach).
I have family from all walks of life so getting input from the OP through email would help him much better and I can share Skype or lync communicator details with him and we can share screens (I know a few factory workers and my dads good at the hardware side of the electronics).
Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth. - "Sherlock holmes" "speak softly and carry a big stick" - theodore roosevelt. Fear leads to anger, anger leads to hate, hate leads to suffering - Yoda. Blog - http://www.computerprofessions.co.nr
- Edited by The Thinker Thursday, February 7, 2013 6:09 PM
Thursday, February 7, 2013 6:05 PM -
Why not just use a archive program that runs at night from the server that pulls the data.
jdweng
Because the terminals need to report their status every 5 minutes, or so. This is the purpose of the text file copying.Thursday, February 7, 2013 7:54 PM -
MonkeyBoy,
Again, you are right. But I am the vendor to these companies and I must be proactive on my technical recommendations/constraints. My customers often do not have many IT resources and rely on my advice. I'd like to find solutions that can be applicable to every customer. Less is best.
Thursday, February 7, 2013 8:01 PM -
I forgot to mention their is a registry hack that causes a user to be logged on automatically every time the computer is started here (that way you just need a generic active directory or regular username for the machines the operators use):
http://www.computerperformance.co.uk/windows7/windows7_auto_logon.htm
The thinker,
Sounds cool ! I'll try that !
Thursday, February 7, 2013 8:07 PM -
MonkeyBoy,
Again, you are right. But I am the vendor to these companies and I must be proactive on my technical recommendations/constraints. My customers often do not have many IT resources and rely on my advice. I'd like to find solutions that can be applicable to every customer. Less is best.
I don't know if you're interested but there is a totally free awesome protocol analyzer that you can use called Wireshark that also requires WinPCap and you can use it to look at all of the data on the network your computer is connected to. Just in case you ever have a need to see, for example, if your computer is receiving data from a TCP Transmitter to verify that you are getting data if your TCP Receiver isn't receiving anything or to verify you aren't getting data.
Anyhow it's not DEMO and Wireshark provides great support for this product. I've used various versions of it over the years as well as various verisions of WinPCap and never had a problem.
You've taught me everything I know but not everything you know.
Thursday, February 7, 2013 9:56 PM