樓主你好,你所指的那個(gè)指令就是"winchat",Windows自帶的局域網(wǎng)聊天工具.使用方法:開始--運(yùn)行--輸入winchat,就可以打開Winchat了.只能實(shí)現(xiàn)很簡單的功能,并且是中文,沒什么好介紹的,相信你一看就懂,希望可以幫到你!
武勝網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)公司!從網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、響應(yīng)式網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營維護(hù)。創(chuàng)新互聯(lián)公司2013年開創(chuàng)至今到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)公司。
ps:你所說的電影是杜拉拉升職記吧?貌似那是用的郵件發(fā)的,不小心點(diǎn)成群發(fā)了~嘿嘿..
【ClientSocketDemo.java 客戶端Java源代碼】 import java.net.*; import java.io.*; public class
ClientSocketDemo { //聲明客戶端Socket對象socket Socket socket = null; //聲明客戶器端數(shù)據(jù)輸入輸出流
DataInputStream in; DataOutputStream out; //聲明字符串?dāng)?shù)組對象response,用于存儲(chǔ)從服務(wù)器接收到的信息
String response[]; //執(zhí)行過程中,沒有參數(shù)時(shí)的構(gòu)造方法,本地服務(wù)器在本地,取默認(rèn)端口10745 public ClientSocketDemo() { try {
//創(chuàng)建客戶端socket,服務(wù)器地址取本地,端口號為10745 socket = new Socket("localhost",10745);
//創(chuàng)建客戶端數(shù)據(jù)輸入輸出流,用于對服務(wù)器端發(fā)送或接收數(shù)據(jù) in = new DataInputStream(socket.getInputStream());
out = new DataOutputStream(socket.getOutputStream()); //獲取客戶端地址及端口號 String ip =
String.valueOf(socket.getLocalAddress()); String port =
String.valueOf(socket.getLocalPort()); //向服務(wù)器發(fā)送數(shù)據(jù) out.writeUTF("Hello
Server.This connection is from client."); out.writeUTF(ip); out.writeUTF(port);
//從服務(wù)器接收數(shù)據(jù) response = new String[3]; for (int i = 0; i response.length;
i++) { response[i] = in.readUTF(); System.out.println(response[i]); } }
catch(UnknownHostException e){e.printStackTrace();} catch(IOException
e){e.printStackTrace();} } //執(zhí)行過程中,有一個(gè)參數(shù)時(shí)的構(gòu)造方法,參數(shù)指定服務(wù)器地址,取默認(rèn)端口10745 public
ClientSocketDemo(String hostname) { try {
//創(chuàng)建客戶端socket,hostname參數(shù)指定服務(wù)器地址,端口號為10745 socket = new Socket(hostname,10745);
in = new DataInputStream(socket.getInputStream()); out = new
DataOutputStream(socket.getOutputStream()); String ip =
String.valueOf(socket.getLocalAddress()); String port =
String.valueOf(socket.getLocalPort()); out.writeUTF("Hello Server.This
connection is from client."); out.writeUTF(ip); out.writeUTF(port); response =
new String[3]; for (int i = 0; i response.length; i++) { response[i] =
in.readUTF(); System.out.println(response[i]); } } catch(UnknownHostException
e){e.printStackTrace();} catch(IOException e){e.printStackTrace();} }
//執(zhí)行過程中,有兩個(gè)個(gè)參數(shù)時(shí)的構(gòu)造方法,第一個(gè)參數(shù)hostname指定服務(wù)器地址 //第一個(gè)參數(shù)serverPort指定服務(wù)器端口號 public
ClientSocketDemo(String hostname,String serverPort) { try { socket = new
Socket(hostname,Integer.parseInt(serverPort)); in = new
DataInputStream(socket.getInputStream()); out = new
DataOutputStream(socket.getOutputStream()); String ip =
String.valueOf(socket.getLocalAddress()); String port =
String.valueOf(socket.getLocalPort()); out.writeUTF("Hello Server.This
connection is from client."); out.writeUTF(ip); out.writeUTF(port); response =
new String[3]; for (int i = 0; i response.length; i++) { response[i] =
in.readUTF(); System.out.println(response[i]); } } catch(UnknownHostException
e){e.printStackTrace();} catch(IOException e){e.printStackTrace();} } public
static void main(String[] args) { String comd[] = args; if(comd.length == 0) {
System.out.println("Use localhost(127.0.0.1) and default port");
ClientSocketDemo demo = new ClientSocketDemo(); } else if(comd.length == 1) {
System.out.println("Use default port"); ClientSocketDemo demo = new
ClientSocketDemo(args[0]); } else if(comd.length == 2) {
System.out.println("Hostname and port are named by user"); ClientSocketDemo demo
= new ClientSocketDemo(args[0],args[1]); } else System.out.println("ERROR"); } }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
【ServerSocketDemo.java 服務(wù)器端Java源代碼】 import java.net.*; import java.io.*; public
class ServerSocketDemo { //聲明ServerSocket類對象 ServerSocket serverSocket;
//聲明并初始化服務(wù)器端監(jiān)聽端口號常量 public static final int PORT = 10745; //聲明服務(wù)器端數(shù)據(jù)輸入輸出流
DataInputStream in; DataOutputStream out; //聲明InetAddress類對象ip,用于獲取服務(wù)器地址及端口號等信息
InetAddress ip = null; //聲明字符串?dāng)?shù)組對象request,用于存儲(chǔ)從客戶端發(fā)送來的信息 String request[];
public ServerSocketDemo() { request = new String[3]; //初始化字符串?dāng)?shù)組 try {
//獲取本地服務(wù)器地址信息 ip = InetAddress.getLocalHost();
//以PORT為服務(wù)端口號,創(chuàng)建serverSocket對象以監(jiān)聽該端口上的連接 serverSocket = new ServerSocket(PORT);
//創(chuàng)建Socket類的對象socket,用于保存連接到服務(wù)器的客戶端socket對象 Socket socket =
serverSocket.accept(); System.out.println("This is
server:"+String.valueOf(ip)+PORT); //創(chuàng)建服務(wù)器端數(shù)據(jù)輸入輸出流,用于對客戶端接收或發(fā)送數(shù)據(jù) in = new
DataInputStream(socket.getInputStream()); out = new
DataOutputStream(socket.getOutputStream()); //接收客戶端發(fā)送來的數(shù)據(jù)信息,并顯示 request[0] =
in.readUTF(); request[1] = in.readUTF(); request[2] = in.readUTF();
System.out.println("Received messages form client is:");
System.out.println(request[0]); System.out.println(request[1]);
System.out.println(request[2]); //向客戶端發(fā)送數(shù)據(jù) out.writeUTF("Hello client!");
out.writeUTF("Your ip is:"+request[1]); out.writeUTF("Your port
is:"+request[2]); } catch(IOException e){e.printStackTrace();} } public static
void main(String[] args) { ServerSocketDemo demo = new ServerSocketDemo(); } }
或者看這里java外網(wǎng)聊天室:
參考地址:
第一個(gè)問題 qq聊天室 必須能 用vb都可以做
第二個(gè)問題 vb.net插入數(shù)學(xué)公式 可以把這些公式封裝到一個(gè)類中,調(diào)用就是了
1. error_Renamed = FirmwareVersionGet(SocketID, Buffer)
執(zhí)行FirmwareVersionGet函數(shù),返回值賦值給error_Renamed。
根據(jù)FirmwareVersionGet函數(shù)名稱估計(jì)是取得Firmware的版本號。
2. TCP_CloseSocket((SocketID))
執(zhí)行TCP_CloseSocket函數(shù),根據(jù)名字功能估計(jì)是關(guān)閉TCP連接。
3. ret = ErrorStringGet(SocketID, error_Renamed, Buffer)
執(zhí)行ErrorStringGet函數(shù),返回值賦值給ret。
根據(jù)函數(shù)名稱估計(jì)是取得異常(錯(cuò)誤)文字資料說明。
4. LogWrite(vbCrLf "Port Close" Buffer)
執(zhí)行LogWrite函數(shù),根據(jù)名字功能估計(jì)是寫Log記錄。
5. LogWrite(vbCrLf CStr(error_Renamed))
同上,
里面的CStr(error_Renamed)是什么意思?我查過了想確認(rèn)。是把error_Renamed轉(zhuǎn)為字符型數(shù)據(jù),前面沒有空格,對吧。正確
6. error_Renamed = PositionerSGammaParametersGet(SocketID, PositionerName3, vel, acc, Jerkmax, Jerkmin)
執(zhí)行PositionerSGammaParametersGet函數(shù),返回值賦值給error_Renamed 。
根據(jù)函數(shù)名稱估計(jì)是取得位置參數(shù)。
將光標(biāo)放在該函數(shù)上,單擊鼠標(biāo)右鍵,點(diǎn)選Definition(vb.net是Go To Definition)
7. error_Renamed = GroupMoveAbsolute(SocketID, txtGroup.Text, 3, dbl_arry(0))
估計(jì)是將某群組移動(dòng)到指定位置吧,這個(gè)比較難猜。
8. error_Renamed = GroupPositionCurrentGet(SocketID, PositionerName1, 1, position)
估計(jì)是取得某群組的當(dāng)前位置
9. Public CommOpened As Boolean 好多程序段中都有If CommOpened = False Then 那么下面的程序才能執(zhí)行,我想問的是 在怎么才能控制布爾型變量CommOpened 為TURE 或FALSE呢?好多程序都是在這個(gè)條件下才能執(zhí)行下一部分的。
你看看是否有CommOpened=函數(shù)(參數(shù)[可選])這一類的語句,又或者將Commopened作為參數(shù)傳入某函數(shù),而該參數(shù)是Byref來定義的。這些語句都會(huì)變更變量的值。
10. Buffer = New String(Chr(0), 512 + 1)
將513個(gè)Chr(0)連成字符串賦值給Buffer.
11. If CommOpened = FalseThen
SocketID = TCP_ConnectToServer(IPAddress, IPPort, 10)
問題 CommOpened = False這一點(diǎn)怎么控制呢,布爾的如何讓他為False呢?
第9題已回答
SocketID = TCP_ConnectToServer(IPAddress, IPPort, 10)
建議TCP連接,將ID賦值 給SocketID.
If SocketID -1 Then
error_Renamed = FirmwareVersionGet(SocketID, Buffer)
問題 SocketID是什么,為什么不等于1才執(zhí)行下的程序??梢再x其他的值嗎?
根據(jù)你提供的代碼,SockedID在這里的定義應(yīng)該是TCP成功連接後的一個(gè)連接身份證號(成功的話通常都是一個(gè)大於0的值),如果是-1的話則表示連接不成功,只是不是-1的話就表示成功。
FirmwareVersionGet(SocketID, Buffer)
第一題已解釋。
LogWrite(vbCrLf Buffer)
第4題已解釋。Buffer的值第9題已解釋,就如CommOpened如何賦值的道理一樣。
12. TCP_CloseSocket((SocketID))
第二題已解釋
SocketID = -1
第11題已解釋
13. If CommOpened = TrueThen
error_Renamed = FirmwareVersionGet(SocketID, Buffer)
第11題已解釋
14. Dim vel AsDouble
txtVelX.Text = Str(vel)
vel沒有具體的值,這個(gè)程序不管用吧,在沒有具體值的情況下不能用吧。調(diào)試了一個(gè)返回值為0.實(shí)際程序里面就是這樣寫的,不解。
vel可能為任意值,如果是VB6的話,未初始化的變量一般為0.
15. If CommOpened = True Then
error_Renamed = GroupInitialize(SocketID, GroupName)
當(dāng)CommOpened這個(gè)變量為True時(shí),執(zhí)行GroupInitialize函數(shù),并將返回值賦值給error_Renamed.GroupInitialize估計(jì)是某群組初始化函數(shù)。
16. If CommOpened = TrueThen
error_Renamed = GroupHomeSearch(SocketID, GroupName)
GroupHomeSearch這個(gè)函數(shù)很難猜出它的功能,估計(jì)是搜尋某群組吧。
17. If CommOpened = TrueThen
error_Renamed = GroupKill(SocketID, GroupName)
GroupKill估計(jì)是刪除某群組
18. Text1.AppendText(Logstr vbCrLf)
Text1如果是Textbox控件的話,這個(gè)語句則表示在Text1這個(gè)TextBox內(nèi)添加變量Logstr的內(nèi)容再加上一個(gè)回車符
Text1.ScrollToCaret()Textbox將滾動(dòng)條自動(dòng)滾動(dòng)到插入符的位置。
綜合你以上問題,這個(gè)應(yīng)該是一個(gè)用VB.net寫的一個(gè)聊天室程序。
‘客戶端向這樣寫:在窗體說放兩個(gè)文本框、兩個(gè)標(biāo)簽、兩個(gè)按鈕、一個(gè)列表框
Imports System.Net
Imports System.Net.Sockets
Imports System.IO
Imports System.Threading
Public Class Form1
'網(wǎng)絡(luò)基礎(chǔ)數(shù)據(jù)流
Private ns As NetworkStream
Private swriter As StreamWriter
Private nsread As StreamReader
Private tcpclient As TcpClient
Private tcpconnected As Boolean = False
Private clisocket As Socket
Private mythread As Thread
'發(fā)送
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.TextBox2.Text "" Then
swriter.WriteLine(Me.TextBox2.Text)
swriter.Flush()
Me.TextBox2.Text = ""
Else
MessageBox.Show("發(fā)送信息不能為空!", "錯(cuò)誤提示")
End If
End Sub
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'建立連連接
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim ipremote As IPAddress
Dim tcpclient As TcpClient
Try
ipremote = IPAddress.Parse(Me.TextBox1.Text)
Catch ex As Exception
MessageBox.Show("IP地址不合法!", "錯(cuò)誤提示")
End Try
Try
tcpclient = New TcpClient(Me.TextBox1.Text, 8000)
ns = tcpclient.GetStream
swriter = New StreamWriter(ns)
Me.StatusBar1.Text = "已經(jīng)連接上"
Me.Button2.Enabled = False
Me.Button1.Enabled = True
tcpconnected = True
Catch ex As Exception
MessageBox.Show("無法與遠(yuǎn)程8000端口建立連接!", "錯(cuò)誤提示")
End Try
End Sub
Private Sub listen()
Try
Dim tcplistener As New TcpListener(IPAddress.Parse("127.0.0.1"), 8000)
tcplistener.Start()
tcpclient = tcplistener.AcceptTcpClient
ns = tcpclient.GetStream()
nsread = New StreamReader(ns)
While True
Dim msg As String = nsread.ReadLine
If msg = "stop" Then
tcplistener.Stop()
ns.Close()
nsread.Close()
mythread.Abort()
Else
Dim mytime As String = DateTime.Now.ToShortTimeString
Me.ListBox1.Items.Add(mytime + " " + msg)
End If
End While
Catch ex As System.Security.SecurityException
MessageBox.Show("偵聽失??!", "錯(cuò)誤")
End Try
End Sub
End Class
VB.NET Code
My.Computer.Audio.Play("SoundFile.wav", AudioPlayMode.BackgroundLoop) ‘連續(xù)循環(huán)播放
My.Computer.Audio.Stop() ‘停止播放
My.Computer.Audio.Play("C:\WINDOWS\Media\Windows XP 注銷音.wav", AudioPlayMode.WaitToComplete) ’僅播放一次
SoundFile.wav是您的音頻文件,自己更換一下即可。
希望能幫到您