我正在寫一個C#P2P視頻聊天(我的考試的一部分在教師),我有點卡住通過udp發送數據。所以這裏它是如何工作的。我有一個Web_Capture庫,每一個拍攝圖像時都會將PictureBox的圖像捕獲的一個UDP客戶端錯誤 - 無法發送數據字節
private void webCamCapture_ImageCaptured(object source, WebCam_Capture.WebcamEventArgs e)
{
myCamera.Image = e.WebCamImage;
sendData(ref ipep2); // send it immediately
}
所以後來SendData方法開始發送...
private void sendData(ref IPEndPoint sender)
{
byte[] data;
if (friendsClient == null)
{
friendsClient = new UdpClient();
}
MemoryStream myStream = new MemoryStream();
myCamera.Image.Save(myStream, System.Drawing.Imaging.ImageFormat.Jpeg);
data = myStream.GetBuffer();
friendsClient.Send(data, data.Length,sender);
}
當我調試,插座異常彈出:
System.Net.Sockets.SocketException was unhandled by user code
Message=The requested address is not valid in its context
Source=System
ErrorCode=10049
NativeErrorCode=10049
是這樣,沒有人有任何想法,我會心存感激,如果他支持與代碼的想法,因爲我在C#:)在此先感謝我nooby。馬裏安
什麼是價值'ipep2'? – 2012-03-24 21:45:15