校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > asp.net使用Socket.Send發送信息及Socket.SendFile傳輸文件的方法

asp.net使用Socket.Send發送信息及Socket.SendFile傳輸文件的方法

熱門標簽:電話機器人鑰匙扣 400電話唐山辦理 威力最大的電銷機器人 電銷專用外呼線路 電銷外呼系統是違法的嗎 旅游地圖標注線路 漯河外呼調研線路 地圖標注位置怎么弄圖 廣西房產智能外呼系統推薦

本文實例講述了asp.net使用Socket.Send發送信息及Socket.SendFile傳輸文件的方法。分享給大家供大家參考,具體如下:

// Displays sending with a connected socket
// using the overload that takes a buffer.
public static int SendReceiveTest1(Socket server)
{
  byte[] msg = Encoding.UTF8.GetBytes("This is a test");
  byte[] bytes = new byte[256];
  try
  {
    // Blocks until send returns.
    int i = server.Send(msg);
    Console.WriteLine("Sent {0} bytes.", i);
    // Get reply from the server.
    i = server.Receive(bytes);
    Console.WriteLine(Encoding.UTF8.GetString(bytes));
  }
  catch (SocketException e)
  {
    Console.WriteLine("{0} Error code: {1}.", e.Message, e.ErrorCode);
    return (e.ErrorCode);
  }
  return 0;
}

// Establish the local endpoint for the socket.
IPHostEntry ipHost = Dns.GetHostEntry(Dns.GetHostName());
IPAddress ipAddr = ipHost.AddressList[0];
IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 11000);
// Create a TCP socket.
Socket client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
// Connect the socket to the remote endpoint.
client.Connect(ipEndPoint);
// There is a text file test.txt located in the root directory.
string fileName = "C:\\test.txt";
// Send file fileName to remote device
Console.WriteLine("Sending {0} to the host.", fileName);
client.SendFile(fileName);
// Release the socket.
client.Shutdown(SocketShutdown.Both);
client.Close();

更多關于asp.net相關內容感興趣的讀者可查看本站專題:《asp.net操作json技巧總結》、《asp.net字符串操作技巧匯總》、《asp.net操作XML技巧總結》、《asp.net文件操作技巧匯總》、《asp.net ajax技巧總結專題》及《asp.net緩存操作技巧總結》。

希望本文所述對大家asp.net程序設計有所幫助。

您可能感興趣的文章:
  • Asp.net Socket客戶端(遠程發送和接收數據)
  • c#(Socket)異步套接字代碼示例
  • C#使用Socket發送和接收TCP數據實例
  • c#(Socket)同步套接字代碼示例
  • C#實現的Socket服務器端、客戶端代碼分享
  • C#中使用Socket獲取網頁源代碼的代碼
  • C#中異步Socket通信編程代碼實例
  • C#之Socket操作類實例解析
  • 使用C#開發Socket通訊的方法
  • C#使用Socket實現發送和接收圖片的方法
  • C# Socket網絡編程實例
  • c# socket編程udp客戶端實現代碼分享

標簽:試駕邀約 銅陵 湖北 欽州 焦作 湘西 無錫 綏化

巨人網絡通訊聲明:本文標題《asp.net使用Socket.Send發送信息及Socket.SendFile傳輸文件的方法》,本文關鍵詞  asp.net,使用,Socket.Send,發送,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《asp.net使用Socket.Send發送信息及Socket.SendFile傳輸文件的方法》相關的同類信息!
  • 本頁收集關于asp.net使用Socket.Send發送信息及Socket.SendFile傳輸文件的方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 都匀市| 达拉特旗| 上犹县| 宜阳县| 本溪市| 肥东县| 前郭尔| 纳雍县| 晋中市| 闽侯县| 安溪县| 二连浩特市| 白河县| 慈溪市| 新巴尔虎左旗| 西华县| 宜城市| 无锡市| 翼城县| 涪陵区| 怀化市| 武安市| 项城市| 色达县| 台州市| 景宁| 津南区| 会昌县| 岫岩| 中方县| 正镶白旗| 天峻县| 汝城县| 永寿县| 忻城县| 雅江县| 嘉祥县| 绥宁县| 巧家县| 武陟县| 资中县|