Click here to Skip to main content
15,903,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ok. i have a project that have a server side and client side

when client send a link the server download it convert the file and send link do clint to download the file...
the server send how much % the server convert from the file and send the % in loop until its 100%

my problem its when i send link from client its start to convert and show the %
buy if i send from 2 clints in 2 diffrent computers its stop to send % value to the first sender and start to send to the last clent that send link.

i dont understand why its not send to 2 clients value for specific file he send to the server

i use the netcomm liberary from codeproject
(
.NET Multi-user Communication Library (TCP)
)

please help.


the code



C#
Private Sub DataReceived(ByVal ID As String, ByVal Data() As Byte) Handles Host.DataReceived

    Dim TAB As New WBTab(NetComm.Host.ConvertFromAscii(Data)) 'create a new tab with URL
    TabControl1.TabPages.Add(TAB) 'show it
    wait(3)
    Dim a1 As String
    a1 = TAB.Text
    Host.SendData(ID, Host.Convert2Ascii(TAB.Text))
    '//////////////////////////////////////////////////////////////]
    Dim FileName = a1.Substring(a1.LastIndexOf("/") + 1)
    Dim appPath As String = Application.StartupPath()

    Dim item1 As ListViewItem = ListViewEx.FindItemWithText(FileName)
    'if the file is in the listview. transfer to the client
    If (item1 IsNot Nothing) Then
        Dim col1 As String = ListViewEx.Items.Item(item1.Index).SubItems(1).Text
        Dim col3 As String = ListViewEx.Items.Item(item1.Index).SubItems(3).Text
        Host.SendData(ID, Host.Convert2Ascii("The File Is in convert, wait until it finish " + " Completed - " + col3 + " From - " + col1))
        Do
            If ListBox1.Items.Contains(ID) = False Then
                Exit Do
            End If
            Host.SendData(ID, Host.Convert2Ascii("The File Is in convert, wait until it finish " + " Completed - " + col3 + " From - " + col1))
            If col1 = col3 Then
                Host.SendData(ID, Host.Convert2Ascii("Downloading"))
                wait(1)
                sendans(ID, Host.Convert2Ascii("http://233.249.162.155/" + item1.Text))
                Exit Do
            End If
        Loop
    Else
        'if the file is not in list view. download it and add to list view. when its finish, send download link to the client
        ListViewEx.StartDownload(a1, Path.Combine(appPath, FileName))
        wait(1)
        Host.SendData(ID, Host.Convert2Ascii("The File successfully added to the converter! wait for finish and then the file will tansfer to you "))
        wait(1)
        Do
            If ListBox1.Items.Contains(ID) = False Then
                Exit Do
            End If

            Dim item111 As ListViewItem = ListViewEx.FindItemWithText(FileName)
            Dim col11 As String = ListViewEx.Items.Item(item111.Index).SubItems(1).Text
            Dim col13 As String = ListViewEx.Items.Item(item111.Index).SubItems(3).Text
            wait(1)
            Host.SendData(ID, Host.Convert2Ascii(col13 + " From " + col11))
            If col11 = col13 Then
                If ListBox1.Items.Contains(ID) = True Then
                    Dim item1111 As ListViewItem = ListViewEx.FindItemWithText(FileName)
                    Host.SendData(ID, Host.Convert2Ascii("Downloading"))
                    wait(1)
                    sendans(ID, Host.Convert2Ascii("http://233.249.162.155/" + item1111.Text))
                End If
            End If
        Loop
    End If
End Sub


What I have tried:

Private Sub DataReceived(ByVal ID As String, ByVal Data() As Byte) Handles Host.DataReceived

Dim TAB As New WBTab(NetComm.Host.ConvertFromAscii(Data)) 'create a new tab with URL
TabControl1.TabPages.Add(TAB) 'show it
wait(3)
Dim a1 As String
a1 = TAB.Text
Host.SendData(ID, Host.Convert2Ascii(TAB.Text))
'//////////////////////////////////////////////////////////////]
Dim FileName = a1.Substring(a1.LastIndexOf("/") + 1)
Dim appPath As String = Application.StartupPath()

Dim item1 As ListViewItem = ListViewEx.FindItemWithText(FileName)
'if the file is in the listview. transfer to the client
If (item1 IsNot Nothing) Then
Dim col1 As String = ListViewEx.Items.Item(item1.Index).SubItems(1).Text
Dim col3 As String = ListViewEx.Items.Item(item1.Index).SubItems(3).Text
Host.SendData(ID, Host.Convert2Ascii("The File Is in convert, wait until it finish " + " Completed - " + col3 + " From - " + col1))
Do
If ListBox1.Items.Contains(ID) = False Then
Exit Do
End If
Host.SendData(ID, Host.Convert2Ascii("The File Is in convert, wait until it finish " + " Completed - " + col3 + " From - " + col1))
If col1 = col3 Then
Host.SendData(ID, Host.Convert2Ascii("Downloading"))
wait(1)
sendans(ID, Host.Convert2Ascii("http://233.249.162.155/" + item1.Text))
Exit Do
End If
Loop
Else
'if the file is not in list view. download it and add to list view. when its finish, send download link to the client
ListViewEx.StartDownload(a1, Path.Combine(appPath, FileName))
wait(1)
Host.SendData(ID, Host.Convert2Ascii("The File successfully added to the converter! wait for finish and then the file will tansfer to you "))
wait(1)
Do
If ListBox1.Items.Contains(ID) = False Then
Exit Do
End If

Dim item111 As ListViewItem = ListViewEx.FindItemWithText(FileName)
Dim col11 As String = ListViewEx.Items.Item(item111.Index).SubItems(1).Text
Dim col13 As String = ListViewEx.Items.Item(item111.Index).SubItems(3).Text
wait(1)
Host.SendData(ID, Host.Convert2Ascii(col13 + " From " + col11))
If col11 = col13 Then
If ListBox1.Items.Contains(ID) = True Then
Dim item1111 As ListViewItem = ListViewEx.FindItemWithText(FileName)
Host.SendData(ID, Host.Convert2Ascii("Downloading"))
wait(1)
sendans(ID, Host.Convert2Ascii("http://233.249.162.155/" + item1111.Text))
End If
End If
Loop
End If
End Sub
Posted
Comments
Garth J Lancaster 12-Jun-16 21:16pm    
if this is the article to which you refer http://www.codeproject.com/Articles/118485/C-VB-NET-Multi-user-Communication-Library-TCP I think you'd be better off posting your question to that article so the author may see and help you .. fwiw, it seems this was written as a school project, so wether its 'robust' enough for your needs remains to be seen

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900