View Single Post
 
Old 06-09-2013, 05:39 AM
cyprus1989 cyprus1989 is offline
Newcomer
 
Join Date: Jun 2013
Posts: 1
Unhappy Client Server App

i want to make a server/client app. i do it but i want to add and something else.When i add a new client,what is send to the server i want also to inform and the other client..here ise the client server:
-------------------------------------------------------------------------
Option Explicit On
Imports System.IO
Imports System.Net.Sockets
Public Class Form1
Dim client As TcpClient

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Try
client = New TcpClient(AxWinsock1.LocalIP, 65534)
Dim writer As New StreamWriter(client.GetStream())
Dim nickname As New StreamWriter(client.GetStream())

writer.Write(TextBox3.Text & "say:" & TextBox1.Text)
ListBox1.Items.Add(TextBox3.Text & " say:" & TextBox1.Text)
writer.Flush()
TextBox1.Text = ""
TextBox3.Text = ""
Catch ex As Exception
MsgBox(ex.Message)
End Try
------------------------------------------------------------------------
and here is the server user:
Option Explicit On
Imports System.IO
Imports System.Net.Sockets
Public Class Form1
Dim Listener As New TcpListener(65534)
Dim Client As TcpClient

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Listener.Stop()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Start()
Listener.Start()
End Sub

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim message As String
If Listener.Pending = True Then
message = ""
Client = Listener.AcceptTcpClient()
Dim reader As New StreamReader(Client.GetStream())
While reader.Peek > -1
message &= Convert.ToChar(reader.Read()).ToString
End While
ListBox1.Items.Add(message)
End If
End Sub
--------------------------------------------------------------------------
that i want is to when i creat a new client the send message also i want to go and the other client.
Please help me
Reply With Quote