Socket類連接后 可以通過類中的 RemoteEndPoint 來獲取遠(yuǎn)程IP和端口信息.
創(chuàng)新互聯(lián)長(zhǎng)期為近千家客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營(yíng)造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為田陽企業(yè)提供專業(yè)的成都做網(wǎng)站、網(wǎng)站建設(shè),田陽網(wǎng)站改版等技術(shù)服務(wù)。擁有十年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
要注意的是.需要將它強(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)
socket如何繞過代理服務(wù)器連接-CSDN論壇-CSDN.NET-...
服務(wù)器 socket ie 我實(shí)驗(yàn)室的電腦都是用IE代理服務(wù)器上網(wǎng),如何編寫套接字連接到外面的服務(wù)器,新手求老師...
什么IIS架構(gòu)。暈~~~
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ù)器上。簡(jiǎn)單一點(diǎn)的方法是右鍵點(diǎn)擊項(xiàng)目文件夾,Web共享——共享文件夾。此時(shí)就算發(fā)布成功了。不過還有一些細(xì)節(jié)需要注意。如:IIS匿名訪問等。那就是另外的問題了。呵呵。IIS設(shè)置很簡(jiǎn)單,可以在網(wǎng)上找些資料。
如果只是檢測(cè)能否瀏覽網(wǎng)頁(yè)就 PING DNS服務(wù)器 看返回值。
下載就PING 網(wǎng)關(guān)。
我當(dāng)然是知道是在運(yùn)行中~ if ping 返回值 0 then msgbox "連接有問題"
給你代碼吧。一個(gè)COMMAND控件 代碼如下
Dim eR As EIGCInternetConnectionState
Dim sMsg As String
Dim sName As String
Dim bConnected As Boolean
Private Declare Function InternetSetDialState Lib "wininet.dll" _
(ByVal lpszConnectoid As String, ByVal dwState As Long, _
ByVal dwReserved As Long) As Long
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _
Alias "InternetGetConnectedStateExA" _
(ByRef lpdwFlags As Long, _
ByVal lpszConnectionName As String, _
ByVal dwNameLen As Long, _
ByVal dwReserved As Long _
) As Long
Private Enum EIGCInternetConnectionState
INTERNET_CONNECTION_MODEM = H1
INTERNET_CONNECTION_LAN = H2
INTERNET_CONNECTION_PROXY = H4
INTERNET_RAS_INSTALLED = H10
INTERNET_CONNECTION_OFFLINE = H20
INTERNET_CONNECTION_CONFIGURED = H40
End Enum
Private Function InternetConnected(Optional ByRef eConnectionInfo _
As EIGCInternetConnectionState, Optional ByRef _
sConnectionName As String) As Boolean
Dim dwFlags As Long
Dim sNameBuf As String
Dim lR As Long
Dim iPos As Long
sNameBuf = String$(513, 0)
lR = InternetGetConnectedStateEx(dwFlags, sNameBuf, 512, 0)
eConnectionInfo = dwFlags
iPos = InStr(sNameBuf, vbNullChar)
If iPos 0 Then
sConnectionName = Left$(sNameBuf, iPos - 1)
ElseIf Not sNameBuf = String$(513, 0) Then
sConnectionName = sNameBuf
End If
InternetConnected = (lR = 1)
End Function
Private Sub Command1_Click()
bConnected = InternetConnected(eR, sName)
If (eR And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then
sMsg = sMsg "使用modem連接到Internet." vbCrLf
End If
If (eR And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then
sMsg = sMsg "使用內(nèi)部網(wǎng)連接到Internet." vbCrLf
End If
If (eR And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then
sMsg = sMsg "通過代理服務(wù)器連接到Internet." vbCrLf
End If
If (eR And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then
sMsg = sMsg "現(xiàn)在連接處于離線狀態(tài)." vbCrLf
End If
If (eR And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED Then
sMsg = sMsg "連接已經(jīng)被設(shè)定." vbCrLf
Else
sMsg = sMsg "沒有設(shè)定好的連接." vbCrLf
End If
If (eR And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then
sMsg = sMsg "本機(jī)已經(jīng)安裝了遠(yuǎn)程訪問服務(wù)功能." vbCrLf
End If
If bConnected Then
sMsg = "已連接到Internet,連接名稱: " sName vbCrLf vbCrLf sMsg
Else
sMsg = "沒有連接到Internet,連接名稱: " sName vbCrLf vbCrLf sMsg
End If
MsgBox sMsg
End Sub
建議你使用注冊(cè)表的API進(jìn)行修改
封裝兩個(gè)NET函數(shù)給你
private?string?GetReg(string?RegPath)??取得注冊(cè)表項(xiàng)內(nèi)容
{
string?str="";
RegistryKey?hkml?=?Registry.LocalMachine;?
RegistryKey?software?=?hkml.OpenSubKey("SOFTWARE",true);?
RegistryKey?aimdir?=?software.OpenSubKey("krabs",true);
if?(aimdir?!=?null)
{
if?(aimdir.GetValue(RegPath)?!=?null)
str?=?aimdir.GetValue(RegPath).ToString();
if?(str?!=?null)
return?str;
return?null;
}
return?null;
}
private?bool?SetReg(string?RegPath,string?Data)??//設(shè)置注冊(cè)表內(nèi)容
{
RegistryKey?reg?=?Registry.LocalMachine;
RegistryKey?software?=?reg.OpenSubKey("SOFTWARE",?true);
RegistryKey?aimdir1?=?software.CreateSubKey("krabs");
if?(aimdir1?==?null)
return?false;
aimdir1.SetValue(RegPath,?Data);
return?true;
}