如何从服务器端调用方法到客户端cide [英] How to call a method from server side to client cide
本文介绍了如何从服务器端调用方法到客户端cide的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在服务器端有一个名为IPCLIENT的方法,它只将客户端ip写入控制台,我需要客户端能够看到它,但我不知道该怎么做,请给我一些简单的解决方案,我只有服务器代码,在此先感谢,这里是代码:
I have a method called IPCLIENT on server side that only writes the clients ip to console, and i need the client to be able to see it but i dont know how to do that and please give me some simple solutions, i only have the server code, thanks in advance and here''s the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace ServeriTcp
{
class Program
{
static byte[] Mesazhi1 { get; set; }
static IPEndPoint clientEp { get; set; }
public static void Main(string[] args)
{
//create socket
Socket sck = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sck.Bind(new IPEndPoint(0, 4000));
sck.Listen(100);
//accepting connection
Socket acc = sck.Accept();
Mesazhi1 = new byte[acc.SendBufferSize];
//accepting the message from client and saveing it to Mesazhi1
int bytesRead = acc.Receive(Mesazhi1);
byte[] eDhena = new byte[bytesRead];
//loops through the bytes that were read
for (int i = 0; i < bytesRead; i++)
{
eDhena[i] = Mesazhi1[i];
}
string Metoda = Encoding.ASCII.GetString(eDhena);
clientEp = (IPEndPoint)acc.RemoteEndPoint;
}
public static void IPCLIENT()
{
Console.WriteLine("clients ip address: " + Program.clientEp.Address);
}
}
}
推荐答案
你只需按如下方式调用客户端方法
每次使用此行进行验证
ibtSearch.Attributes.Add(onClick,javascript:validate(););
u simply call client method as follows
use this line for validate every time
ibtSearch.Attributes.Add("onClick","javascript:validate();");
这篇关于如何从服务器端调用方法到客户端cide的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文