Results 1 to 7 of 7

Thread: winsock chat dataarrival duplicate string help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    137

    Exclamation winsock chat dataarrival duplicate string help

    i need help to remove duplicate string from winsock dataarrival in client side

    i have winsock.getdata strdata

    i get duplicate string because i added some code in server i belive when i get connected to server it request my id 2 times this is why makes duplicate text

    in winsock data arrival how do i remove duplicate text please help.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: winsock chat dataarrival duplicate string help

    Well first you would have to store what has been received then compare what was already received to what you have just gotten and then remove as needed. Your post does not provide any detail so that's about all I could tell you other than that you should check your code and if you really are sending it twice then change that code so it doesn't do that if that is not what you want it to do.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    137

    Re: winsock chat dataarrival duplicate string help

    as u can se the code i added in server for winsock chat

    on connection request i added this



    Private Sub wsserver_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    Dim iNextSocket As Integer
    Dim i As Integer
    Dim J As Integer
    Dim itmx As ListItem

    For i = lstUsers.ListCount - 1 To 0 Step -1
    For J = 0 To List3.ListCount
    If lstUsers.List(i) = List3.List(J) Then
    kickuser
    ' lstUsers.RemoveItem (i)
    Exit For
    End If
    DoEvents
    Next J
    DoEvents
    Next i

    iNextSocket = modServer.FindOpenSocket(Me)

    'for multiple connections
    'Load wsServer(iNextSocket)
    'wsServer(iNextSocket).Accept requestID
    'InsertText "Connected to " & requestID

    'uUser(iNextSocket).Connection = "Connected"
    'uUser(iNextSocket).requestID = requestID


    If Index = 0 Then
    For intMax = 1 To wsServer.count
    On Error GoTo load1
    If wsServer(intMax).Name = "" Then
    End If
    Next intMax
    load1:

    Load wsServer(intMax)
    wsServer(intMax).LocalPort = 0
    wsServer(intMax).Accept requestID
    '' wsServer(iNextSocket).Accept requestID

    ' InsertText "Connected to " & requestID
    uUser(iNextSocket).Connection = "Connected"
    Dim sTest As String
    sTest = requestID
    sTest = RemoveDuplicates(sTest, " ", vbTextCompare)
    requestID = sTest
    uUser(iNextSocket).requestID = requestID
    ' wsServer(intMax).Tag = 1
    List1.AddItem intMax
    Set itmx = ips.ListItems.Add()
    itmx.Text = intMax
    itmx.SubItems(1) = wsServer(intMax).RemoteHostIP
    itmx.SubItems(2) = "unknown"
    itmx.SubItems(3) = "1"
    End If
    End Sub



    because of this its posting duplicate string from 1 user can you help me fix this please

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: winsock chat dataarrival duplicate string help

    This portion should not be done like this, Error handlers should be used to trap errors that you can not easily avoid where here you are depending on an error to occur

    Code:
    For intMax = 1 To wsServer.count
    On Error GoTo load1
    If wsServer(intMax).Name = "" Then
    End If
    Next intMax
    load1:
    Note that it will go to load1 even if no error occurs basically yoru loop just loops until it reaches the end or an error occurs = poor design

    Hard to read your code as it is not properly formatted, you need to use code tags so the indentation remains and allows it to be readable.

    That code also does not seem to show you sending or receiving anything so I do not know how it is supposed to help in locating and removing duplicate data.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    137

    Re: winsock chat dataarrival duplicate string help

    data miser boss can i send you my project boss just add 1 chatroom in listbox and thats all i need i will be very very happy please boss datamiser i worship your work your the best!!!!!!!!!!!!!!!.

    i am just a noob seeking help from a professional programmer if i had the experience i would have done the same for people who need help so datamiser boss please can i post my server and client here and add chatroom please am awaiting reply boss

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: winsock chat dataarrival duplicate string help

    bogaa,

    Did you even look at the client/server I gave you? It's the simplest way to do what you want without all that extra coding you are showing. If you are not interested in what I have shown you then I will refrain from wasting your time.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Oct 2012
    Posts
    137

    Re: winsock chat dataarrival duplicate string help

    datamise i have , can you just do 1 thing sir can you add 1 chatroom on the source you gave me please please

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width