什么IIS架構(gòu)。暈~~~
創(chuàng)新互聯(lián)公司于2013年開始,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目成都網(wǎng)站制作、網(wǎng)站設(shè)計(jì)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元石臺(tái)做網(wǎng)站,已為上家服務(wù),為石臺(tái)各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:13518219792
1.首先正式版本的發(fā)布你必須要Release,不要直接把Debug程序放上去。
2.將所有的.cs文件刪除。vs.net有一個(gè)很方便的工具,“項(xiàng)目——復(fù)制項(xiàng)目”就ok了。
3.windows server2003上一定要安裝了"Internet 信息服務(wù)(IIS)管理器",如果沒有安裝的話可以到“控制面板——添加或刪除程序——添加\刪除WINDOWS組件——應(yīng)用程序服務(wù)器”如果“應(yīng)用程序服務(wù)器”沒有構(gòu)選的話鉤上,放入windows 2003的系統(tǒng)盤安裝。
4.安裝完成之后把項(xiàng)目靠到服務(wù)器上。簡單一點(diǎn)的方法是右鍵點(diǎn)擊項(xiàng)目文件夾,Web共享——共享文件夾。此時(shí)就算發(fā)布成功了。不過還有一些細(xì)節(jié)需要注意。如:IIS匿名訪問等。那就是另外的問題了。呵呵。IIS設(shè)置很簡單,可以在網(wǎng)上找些資料。
Socket類連接后 可以通過類中的 RemoteEndPoint 來獲取遠(yuǎn)程IP和端口信息.
要注意的是.需要將它強(qiáng)制轉(zhuǎn)化為 IPEndPoint類型 然后通過 IPEndPoint.Address以及IPEndPoint.Port來獲取對(duì)應(yīng)的IP及端口
例:
Dim REV_SCK As New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
'這里創(chuàng)建一個(gè)UDP Socket連接的實(shí)例 TCP也是一樣的
'省略SOCKET連接的代碼 當(dāng)SOCKET連接成功后 可以用下面的語句獲取遠(yuǎn)程信息
Dim IP as string ,Port as integer
'定義IP和Port變量 用來保存地址及端口
IP = IPAddress.Parse(CType(REV_SCK.RemoteEndPoint, IPEndPoint).Address.ToString())
Port = IPAddress.Parse(CType(REV_SCK.RemoteEndPoint, IPEndPoint).Port)
這個(gè)不一定,看具體是做什么用,如果只是簡單的數(shù)據(jù)庫做服務(wù)器端 就不用。但是如果是復(fù)雜的就需要。
如果只是讀寫數(shù)據(jù)庫就不用socket ,軟件本身和數(shù)據(jù)庫就有通道連接。除非想在數(shù)據(jù)庫和軟件之間增加一個(gè)自己的中間層
需要出口設(shè)備進(jìn)行映射內(nèi)部地址;或使用打洞技術(shù)穿透NAT,但使用TCP打洞非常困難。
參考
穿透NAT是非常困難的,因?yàn)镹AT的過程中在出口路由器上的Port已經(jīng)不是你定義的iPort了,具體是多少也不固定
客戶端簡單代碼:
Imports System.Net.Sockets
Imports System.IO
Private Output As NetworkStream
Private Writer As BinaryWriter
Private Reader As BinaryReader
Dim StrSend As String
Dim client As New TcpClient '
client.Connect(servIP, 2006)
Output = client.GetStream
Writer = New BinaryWriter(Output)
Reader = New BinaryReader(Output)
StrSend = "字符串"
System.Threading.Thread.Sleep(100)
Writer.Write(StrSend)
Try
Message = Reader.ReadString
If Message = "OK" Then
LBinfo.Text = "成功!" '測(cè)試
Else
LBinfo.Text = "失敗!"
End If
System.Threading.Thread.Sleep(100)
Catch ex As Exception
MessageBox.Show("Client Application Closing!")
Finally
Writer.Close()
Reader.Close()
Output.Close()
client.Close()
End Try
服務(wù)器端
用線程
Imports System.Net.Sockets
Imports System.IO
Imports System.Threading
Imports System.Windows.Forms
Private Connection As Socket
Private readThread As Thread
Private SocketStream As NetworkStream
Private Writer As BinaryWriter
Private Reader As BinaryReader
Public Sub New()
MyBase.New()
'該調(diào)用是 Windows 窗體設(shè)計(jì)器所必需的。
InitializeComponent()
'在 InitializeComponent() 調(diào)用之后添加任何初始化
readThread = New Thread(AddressOf RunServer)
readThread.Start()
End Sub
Public Sub RunServer()
Dim Listener As TcpListener
Try
Listener = New TcpListener(Net.IPAddress.Parse("192.168.1.16"), 2006)
Listener.Start()
While True
Connection = Listener.AcceptSocket 'accept an incoming connection
SocketStream = New NetworkStream(Connection) 'create networkstream object associated with socket
Writer = New BinaryWriter(SocketStream) 'create object for transferring data across stream
Reader = New BinaryReader(SocketStream) 'read string data sent from client
Try
Do
strIncept = Reader.ReadString
strIncept = DataDisp(strIncept) '此處插入數(shù)據(jù)處理程序()
SendInfoToClient(strIncept) 'send to client
Loop While Connection.Connected
Catch ex As Exception
MsgBox(ex.ToString)
Finally
Writer.Close()
Reader.Close()
SocketStream.Close()
End Try
End While
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Public Sub SendInfoToClient(ByVal Info As String)
'Send to client
Try
If Connection.Connected Then
Writer.Write(Info)
Connection.Close()
End If
Catch ex As SocketException
MessageBox.Show(ex.ToString)
End Try
End Sub
整個(gè)過程都有了
'Private?Sub?DataGrid1_Click()
'?If?DataGrid1.Row??0?Then
'?dwbhTXT.Text?=?DataGrid1.Columns(0).Value
'?Text1.Text?=?DataGrid1.Columns(1).Value
'?Adodc2.ConnectionString?=?"Provider=Microsoft.Jet.OLEDB.4.0;Data?Source="??App.Path??"\ktcms.mdb;Jet?OLEDB:Database?Password=701109"
'?Adodc2.RecordSource?=?"select?*?from?consumer?where?用戶編號(hào)="??dwbhTXT.Text
'?Adodc2.Refresh
'?If?Adodc2.Recordset.RecordCount??0?Then
'???Combo1.Text?=?Adodc2.Recordset.Fields("省份").Value
'?End?If
'?End?If
'End?Sub