Tim tai lieu ve Server Client 2

Tags: As String, & &quot, & Socket, End Sub Private Sub, Index As Integer, As Long, neu khong thi, cac anh, anh chi, tham khao, tai lieu, thiet lap, dim, Server, ban


Chao cac anh chi, hien nay em rat muon tham khao ve cach thiet lap Server/Client nho cac anh chi giup tui, neu khong thi cac anh chi giup tui nen tham khao loai sach nao? . Xin chan thanh cam on!

Truong Cong Tuan

Noi toi lam viec co thiet lap mang server - client, may server hay bi hu, toi muon tao them mot server phu nua de khi may chinh co hu thi lay may phu thay vao nhung mang van phai hoat dong lien tuc. Xin huong dan toi cach cai dat nhu vay! Xin cam on.

Thanh Quan

Hoi am:

Em men! Anh viet ra lap trinh nay de em nghien cuu them, ben canh do, anh cung dua ra mot so dia chi Website, em vao day tham khao them nha. http://www.cisco.com va http://www.support.microsoft.com

Creating the Client Option Explicit Private Sub cmdClose_Click()
Winsock1.Close
shpGo.Visible = False
shpWait.Visible = False
shpError.Visible = True
End Sub Private Sub cmdConnect_Click()
Winsock1.RemoteHost = "11.0.0.1" "Change this to your host IP
Winsock1.RemotePort = 1007
Winsock1.Connect
shpGo.Visible = True
txtItem.SetFocus
End Sub Private Sub cmdSend_Click()
If Winsock1.State = sckConnected Then
Winsock1.SendData txtItem.Text
shpGo.Visible = True
Label3.Caption = "Sending Data"
Else
shpGo.Visible = False
shpWait.Visible = False
shpError.Visible = True
Label3.Caption = "Not currently connected to host"
End If
End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim sData As String
Winsock1.GetData sData, vbString
"Label1.Caption = sData
txtPrice.Text = sData
Label3.Caption = "Received Data"
shpGo.Visible = True
shpWait.Visible = False
shpError.Visible = False End Sub Private Sub Winsock1_SendComplete() Label3.Caption = "Completed Data Transmission" End Sub
Creating the Server
" Get clients request from database
strData = "Item = "" & sItemData & """

rs.Open "select * from prices", strConnect, adOpenKeyset, adLockOptimistic
rs.Find strData
strOutData = rs.Fields("Price")
Follow the steps below to create the server: Option Explicit
Dim iSockets As Integer
Dim sServerMsg As String
Dim sRequestID As String

Private Sub Form_Load() Form1.Show
lblHostID.Caption = Socket(0).LocalHostName
lblAddress.Caption = Socket(0).LocalIP
Socket(0).LocalPort = 1007
sServerMsg = "Listening to port: " & Socket(0).LocalPort
List1.AddItem (sServerMsg)
Socket(0).Listen
End Sub Private Sub socket_Close(Index As Integer)
sServerMsg = "Connection closed: " & Socket(Index).RemoteHostIP
List1.AddItem (sServerMsg)
Socket(Index).Close
Unload Socket(Index)
iSockets = iSockets - 1
lblConnections.Caption = iSockets

End Sub Private Sub socket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
sServerMsg = "Connection request id " & requestID & " from " & Socket(Index).RemoteHostIP
If Index = 0 Then
List1.AddItem (sServerMsg)
sRequestID = requestID
iSockets = iSockets + 1
lblConnections.Caption = iSockets
Load Socket(iSockets)
Socket(iSockets).LocalPort = 1007
Socket(iSockets).Accept requestID
End If End Sub Private Sub socket_DataArrival(Index As Integer, ByVal bytesTotal As Long)

Dim sItemData As String
Dim strData As String
Dim strOutData As String
Dim strConnect As String


" get data from client
Socket(Index).GetData sItemData, vbString
sServerMsg = "Received: " & sItemData & " from " & Socket(Index).RemoteHostIP & "(" & sRequestID & ")"
List1.AddItem (sServerMsg)

"strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:Prices.mdb;Persist Security Info=False"
Dim strPath As String

"Change the database path in the text file

Dim fso As New FileSystemObject, txtfile, _
fil1 As File, ts As TextStream Set fil1 = fso.GetFile("path.txt")
" Read the contents of the file.
Set ts = fil1.OpenAsTextStream(ForReading)
strPath = ts.ReadLine
ts.Close
Set fso = Nothing strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Persist Security Info=False;Data Source=" & strPath & _
"; Mode=Read|Write"

Dim rs As New ADODB.Recordset

" Get clients request from database
strData = "Item = "" & sItemData & """

rs.Open "select * from prices", strConnect, adOpenKeyset, adLockOptimistic
rs.Find strData
strOutData = rs.Fields("Price")

"send data to client
sServerMsg = "Sending: " & strOutData & " to " & Socket(Index).RemoteHostIP
List1.AddItem (sServerMsg)
Socket(Index).SendData strOutData

End Sub

Chuc em vui ve!

Phucusa

Gui ban Truong Cong Tuan:

Ban nen tim doc nhung sach noi ve he dieu hanh may chu, vi du nhu Windows 2000 server, luc do ban se biet cach thiet lap mang client/server.

Gui ban Thanh Quan:

May chu cua co quan ban chay HDH gi? Neu la Windows NT or 2000 thi ban co the gan them mot may server nua roi thiet lap cho no la secondary server (cai kia duong nhien da la primary server roi), neu mang cua ban co su dung domain thi thiet lap cho server thu hai la backup domain controller.

Neu ban can biet them chi tiet co the lien he voi toi Địa chỉ email này đang được bảo vệ khỏi chương trình thư rác, bạn cần bật Javascript để xem nó

Duc Thanh

Viet Bao
Thích và chia sẻ bài viết này trên facebook Theo dõi vietbao.vn trên facebook

Tìm hiểu: As String, & &quot, & Socket, End Sub Private Sub, Index As Integer, As Long, neu khong thi, cac anh, anh chi, tham khao, tai lieu, thiet lap, dim, Server, ban

Xem Bản Tiếng Việt Có Dấu: Tìm tài liệu về Server/Client (2)

Ban co the doc ban tieng Viet co dau cua bai viet Tìm tài liệu về Server/Client (2) bang cach nhan chuot vao duong dan tren.

Lien he ve tin Tim tai lieu ve Server Client 2

Nhan xet, hay lien he ve tin Tim tai lieu ve Server Client 2 co the gui bang duong dan o duoi. Ban nen gui kem tieu de bai viet Tim tai lieu ve Server Client 2 de lam tham khao. Bai viet nay thuoc chuyen de Kinh nghiem trong chuyen muc Cong nghe.

Cac tin khac:

Xem tiep ... Kinh nghiem
Kenh Tin RSS Kenh Tin RSS | Du Bao Thoi Tiet | Lich Xem TV | Lien He - Contact | Quang Cao | Viec Lam | Dieu Kien Su Dung | Bao Ve Tinh Rieng Tu | Sitemap

Copyright©2008 VietBao.vn, Thu Vien Thong Tin Tong Hop Viet Nam va The Gioi, phien ban thu nghiem phan mem Viet Bao Viet Nam, beta 1.0