本文整理汇总了C#中Socket.BeginSend方法的典型用法代码示例。如果您正苦于以下问题:C# Socket.BeginSend方法的具体用法?C# Socket.BeginSend怎么用?C# Socket.BeginSend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Socket
的用法示例。
在下文中一共展示了Socket.BeginSend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
public static void Send(Socket client, String data)
{
// Convert the string data to byte data using ASCII encoding.
byte[] byteData = Encoding.ASCII.GetBytes(data);
// Begin sending the data to the remote device.
client.BeginSend(byteData, 0, byteData.Length, 0,
new AsyncCallback(SendCallback), client);
}
示例2: SocketConnection
internal SocketConnection(URIResolver server, SocketRemote client, Socket socket)
: base(server, client)
{
_socket = socket;
setActor(new SocketActor(this));
Buff buff = Buff.getOrCreate();
int position = buff.position();
startWrite(buff);
buff.limit(buff.position());
buff.position(position);
if (Debug.ENABLED)
[email protected](buff.limit());
_socket.BeginSend(buff.getByteBuffer().array(), buff.position(), buff.remaining(), SocketFlags.None, Connected, buff);
BeginReceive();
}
示例3: Send
// TODO: StateObject is hard-coded to max out at 1024 bytes. Please define somewhere consistent.
// TODO: Add RTCs for data size. Should not exceed max or be less than zero.
// TODO: Genericize this to work with other types of data
public void Send(Socket handler, byte[] data)
{
try
{
handler.BeginSend(data, 0, data.Length, 0,
new AsyncCallback(SendCallback), handler);
}
catch (SocketException ex)
{
Debug.LogWarning(ex.Message);
players[handler].isActive = false;
DropConnection(handler);
events.Add(new SocketEvent(new SocketEventArgs(SocketEventArgs.SocketEventType.DROP, players[handler]), null));
}
}
示例4: Send
private static void Send(Socket handler, String data)
{
try
{
// Convert the string data to byte data using ASCII encoding.
byte[] byteData = Encoding.ASCII.GetBytes(data);
// Begin sending the data to the remote device.
handler.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), handler);
}
catch (Exception e)
{
connected = false;
Debug.Log(e.ToString());
}
}
示例5: Send
private static void Send(Socket handler, String data)
{
// Convert the string data to byte data using ASCII encoding.
Response response = new Response();
response.Success = true;
response.Data = data + "Handled by MAIN SEND";
response.SetImage(new System.Drawing.Bitmap("C:/Work/Projects/Tests/ServerClient/TestServer/TestServer/TestImages/GMan.png"));
string s = XMLHelper<Response>.SerializeStringToXML(response);
byte[] byteData = Encoding.ASCII.GetBytes(s);
// Begin sending the data to the remote device.
handler.BeginSend(byteData, 0, byteData.Length, 0,
new AsyncCallback(SendCallback), handler);
}
示例6: AnotherSend
private static void AnotherSend(Socket handler, String data)
{
// Convert the string data to byte data using ASCII encoding.
Response response = new Response();
response.Success = true;
response.Data = data + "Handled by ANOTHER SEND";
string s = XMLHelper<Response>.SerializeStringToXML(response);
byte[] byteData = Encoding.ASCII.GetBytes(s);
// Begin sending the data to the remote device.
handler.BeginSend(byteData, 0, byteData.Length, 0,
new AsyncCallback(SendCallback), handler);
}
示例7: Send
private void Send(Socket socket, byte[] data)
{
LogsSystem.Instance.Print(string.Format("TCP 发送数据({0}):{1}", data.Length, encoding.GetString(data)));
socket.BeginSend(data, 0, data.Length, 0, new AsyncCallback(SendCallback), socket);
}
示例8: Send
private void Send(Socket client, string data)
{
byte[] byteData = Encoding.UTF8.GetBytes(data);
client.BeginSend(byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(SendCallback), client);
}
示例9: SendBinary
private static void SendBinary(Socket client, byte[] data)
{
byte[] byteData = data;
client.BeginSend(byteData, 0, byteData.Length, 0,
new AsyncCallback(SendCallback), client);
}
示例10: SendServer
private static void SendServer(Socket handler, string data)
{
byte[] byteData = Encoding.Unicode.GetBytes(data);
handler.BeginSend(byteData, 0, byteData.Length, 0, SendCallbackServer, handler);
}
示例11: Send
private static void Send(Socket handler, byte[] data, int length)
{
var dataClone = data.Clone();
handler.BeginSend((byte[])dataClone, 0, length, 0,
new AsyncCallback(SendCallback), handler);
}
示例12: Send
private static void Send(Socket handler, String data)
{
try
{
// Convert the string data to byte data using ASCII encoding.
byte[] byteData = Encoding.ASCII.GetBytes(data);
// Begin sending the data to the remote device.
handler.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), handler);
}
catch (Exception e)
{
Debug.Log("[ROTATION_SERVER] Network Exception, trying to reconnect. " + e);
//server.closeConnection();
}
}
示例13: Send
//Sends the message and uses SendCallback()
private void Send(Socket client, String data)
{
try
{
byte[] byteData = Encoding.ASCII.GetBytes(data); // Convert the string data to byte data using ASCII encoding.
client.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), client); // Begin sending
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
log.Debug(ex.ToString());
}
}
示例14: Send
public void Send(Socket client, byte[] byteData)
{
client.BeginSend(byteData, 0, byteData.Length, 0, new AsyncCallback(SendCallback), client);
}
示例15: Send
public void Send(Socket socket, byte[] data, int length)
{
try {
socket.BeginSend(data, 0, length, 0,
new AsyncCallback(SendCallback), socket);
}
catch (Exception e) {
Debug.Log("<color=green>S: Send </color>" + e.ToString());
}
}