This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using namespace System::Net; | |
using namespace System::Net::Sockets; | |
usc = gcnew UdpStateClass(); | |
Socket ^listener = gcnew Socket(AddressFamily::InterNetwork, SocketType::Dgram, ProtocolType::Udp); | |
usc->endPnt = gcnew IPEndPoint(IPAddress::Any, 11000);// | |
usc->udpClt = gcnew UdpClient(11000); //接続相手 | |
usc->udpClt->BeginReceive(gcnew AsyncCallback(this,&Clientwww::Form1::receiveCallback),usc); | |
//コールバック関数の定義 | |
void receiveCallback(IAsyncResult ^ar){ | |
ImageConverter ^imgconv = gcnew ImageConverter(); | |
UdpClient ^uc = (safe_cast<UdpStateClass^>(ar->AsyncState))->udpClt; | |
IPEndPoint ^iep = (safe_cast<UdpStateClass^>(ar->AsyncState))->endPnt; | |
//受信データを配列に格納 | |
receiveData = uc->EndReceive(ar, iep); | |
//コールバック再読み込み | |
usc->udpClt->BeginReceive(gcnew AsyncCallback(this,&Clientwww::Form1::receiveCallback),usc); | |
} |
0 件のコメント:
コメントを投稿