Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Client-Server application

Client-Server application

Scheduled Pinned Locked Moved Visual Basic
sysadminhelptutorialquestion
13 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    Here you go, but google could have helped your faster.[^]

    S Offline
    S Offline
    Subjugate
    wrote on last edited by
    #3

    But is there a different between a chatting application and a sending of data application? Because what i looking for is send of data.

    L 1 Reply Last reply
    0
    • S Subjugate

      But is there a different between a chatting application and a sending of data application? Because what i looking for is send of data.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #4

      Text is data, you are sending bytes of information from a client to a server which is destributed to all connected clients. I think it is exactly what you are looking for. If it isn't, google[^] will still help you better then anyone here can/will.

      S 2 Replies Last reply
      0
      • L Lost User

        Text is data, you are sending bytes of information from a client to a server which is destributed to all connected clients. I think it is exactly what you are looking for. If it isn't, google[^] will still help you better then anyone here can/will.

        S Offline
        S Offline
        Subjugate
        wrote on last edited by
        #5

        Ok.. Thanks a lot.

        1 Reply Last reply
        0
        • L Lost User

          Text is data, you are sending bytes of information from a client to a server which is destributed to all connected clients. I think it is exactly what you are looking for. If it isn't, google[^] will still help you better then anyone here can/will.

          S Offline
          S Offline
          Subjugate
          wrote on last edited by
          #6

          Sorry to disturb again.. For the link u pass me.. Is it possible for the server to reply to the client? Because for the current project it is not possible.

          L 1 Reply Last reply
          0
          • S Subjugate

            Sorry to disturb again.. For the link u pass me.. Is it possible for the server to reply to the client? Because for the current project it is not possible.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #7

            Using delegates and events it is possible

            S 1 Reply Last reply
            0
            • L Lost User

              Using delegates and events it is possible

              S Offline
              S Offline
              Subjugate
              wrote on last edited by
              #8

              But there isn't any code inside the server that allow reply right? So can u advise where can i go and find the reply source code and construct a delegate?

              L 1 Reply Last reply
              0
              • S Subjugate

                But there isn't any code inside the server that allow reply right? So can u advise where can i go and find the reply source code and construct a delegate?

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #9

                I don't understand what you mean, "that allow reply". The server code has events inside it to notify the clients of new messages, and to update their view. Everything should be inside there and you're not going to get any much better as an example then that.

                S 1 Reply Last reply
                0
                • L Lost User

                  I don't understand what you mean, "that allow reply". The server code has events inside it to notify the clients of new messages, and to update their view. Everything should be inside there and you're not going to get any much better as an example then that.

                  S Offline
                  S Offline
                  Subjugate
                  wrote on last edited by
                  #10

                  Ya i know what u mean. Create a delegate and when a event is raise run the delegate right? But for the server part i didnt notice any code which allows reply. Can u tell me which part of the code do a reply? They do not have any stream.write on the server side..

                  L 1 Reply Last reply
                  0
                  • S Subjugate

                    Ya i know what u mean. Create a delegate and when a event is raise run the delegate right? But for the server part i didnt notice any code which allows reply. Can u tell me which part of the code do a reply? They do not have any stream.write on the server side..

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #11

                    Dude, did you even READ[^] the bloody website? It says, and I quote

                    http://vb.net-informations.com/communications/vb.net\_chat\_server.htm wrote:

                    When a Chat Client connected to Server , the Server create a new Thread for communication . Here we implement a Class handleClient for handling Client as a separate Thread . The Class handleClient has a function doChat() is handling the communication between the Server side Client Socket and the incoming Client Socket.

                    READ it and analyze the code better. Look at the broadcast method to see how it sends a message to users that a new connection has been established. If you can't figure it out with all that's layed out in front of you then you won't be able to do it at all.

                    S 1 Reply Last reply
                    0
                    • L Lost User

                      Dude, did you even READ[^] the bloody website? It says, and I quote

                      http://vb.net-informations.com/communications/vb.net\_chat\_server.htm wrote:

                      When a Chat Client connected to Server , the Server create a new Thread for communication . Here we implement a Class handleClient for handling Client as a separate Thread . The Class handleClient has a function doChat() is handling the communication between the Server side Client Socket and the incoming Client Socket.

                      READ it and analyze the code better. Look at the broadcast method to see how it sends a message to users that a new connection has been established. If you can't figure it out with all that's layed out in front of you then you won't be able to do it at all.

                      S Offline
                      S Offline
                      Subjugate
                      wrote on last edited by
                      #12

                      I already edited on the code i have and the server do reply to its client but somehow the reply was not the expect result. Somehow the 1st request and reply are correct but the 2nd request and reply onward the application skip the 1st 2 letter of wat i type. I dont understand which part have i gone wrong. I have posted my code, pls advise on my mistake. Thanks a lot. Private Sub doChat() Dim infiniteCounter As Integer Dim requestCount As Integer Dim bytesFrom(10024) As Byte Dim dataFromClient, DataToClient As String Dim sendBytes As [Byte]() Dim serverResponse As String Dim rCount As String requestCount = 0 For infiniteCounter = 1 To 2 infiniteCounter = 1 Try requestCount = requestCount + 1 Dim networkStream As NetworkStream = _ clientSocket.GetStream() networkStream.Read(bytesFrom, 0, CInt(clientSocket.ReceiveBufferSize)) dataFromClient = System.Text.Encoding.ASCII.GetString(bytesFrom) dataFromClient = _ dataFromClient.Substring(0, dataFromClient.IndexOf("$")) msg("From client - " + clNo + " : " + dataFromClient) rCount = Convert.ToString(requestCount) serverResponse = "ok" sendBytes = System.Text.Encoding.ASCII.GetBytes(serverResponse) networkStream.Write(bytesFrom, 0, serverResponse.Length) msg("From Server - " + serverResponse) DataToClient = networkStream.Read(sendBytes, 0, sendBytes.Length) broadcast(dataFromClient, clNo, True) broadcast(serverResponse, "Server", True) Catch ex As Exception MsgBox(ex.ToString) End Try Next End Sub

                      L 1 Reply Last reply
                      0
                      • S Subjugate

                        I already edited on the code i have and the server do reply to its client but somehow the reply was not the expect result. Somehow the 1st request and reply are correct but the 2nd request and reply onward the application skip the 1st 2 letter of wat i type. I dont understand which part have i gone wrong. I have posted my code, pls advise on my mistake. Thanks a lot. Private Sub doChat() Dim infiniteCounter As Integer Dim requestCount As Integer Dim bytesFrom(10024) As Byte Dim dataFromClient, DataToClient As String Dim sendBytes As [Byte]() Dim serverResponse As String Dim rCount As String requestCount = 0 For infiniteCounter = 1 To 2 infiniteCounter = 1 Try requestCount = requestCount + 1 Dim networkStream As NetworkStream = _ clientSocket.GetStream() networkStream.Read(bytesFrom, 0, CInt(clientSocket.ReceiveBufferSize)) dataFromClient = System.Text.Encoding.ASCII.GetString(bytesFrom) dataFromClient = _ dataFromClient.Substring(0, dataFromClient.IndexOf("$")) msg("From client - " + clNo + " : " + dataFromClient) rCount = Convert.ToString(requestCount) serverResponse = "ok" sendBytes = System.Text.Encoding.ASCII.GetBytes(serverResponse) networkStream.Write(bytesFrom, 0, serverResponse.Length) msg("From Server - " + serverResponse) DataToClient = networkStream.Read(sendBytes, 0, sendBytes.Length) broadcast(dataFromClient, clNo, True) broadcast(serverResponse, "Server", True) Catch ex As Exception MsgBox(ex.ToString) End Try Next End Sub

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #13

                        Sorry Can't help you, I don't have the time to audit your code right now. Debug it and you'll find the error.

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups