Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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);
        }
    }
}
Posted

1 solution

u simply call client method as follows
use this line for validate every time
ibtSearch.Attributes.Add("onClick","javascript:validate();");
 
Share this answer
 
Comments
SomethingElse123 24-Apr-13 7:45am    
Actually the client is going to type a string, and depending on the string that is typed, the specific method is going to be called from the server, thats what i need to do, sorry for not clarifying that on my question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900