Click here to Skip to main content
15,886,067 members
Home / Discussions / C#
   

C#

 
GeneralRe: My Regular expression stop at $ sign Pin
Naveed7272-Mar-09 18:48
Naveed7272-Mar-09 18:48 
GeneralRe: My Regular expression stop at $ sign Pin
PIEBALDconsult2-Mar-09 18:51
mvePIEBALDconsult2-Mar-09 18:51 
AnswerRe: My Regular expression stop at $ sign Pin
Shyam K Pananghat2-Mar-09 20:56
Shyam K Pananghat2-Mar-09 20:56 
QuestionRepost : WMI query doesnot return record for user having less previleges!! Pin
Cracked-Down2-Mar-09 18:28
Cracked-Down2-Mar-09 18:28 
QuestionBlocking TCP/IP Client Server Pin
astrovirgin2-Mar-09 17:48
astrovirgin2-Mar-09 17:48 
AnswerRe: Blocking TCP/IP Client Server Pin
Jimmanuel3-Mar-09 3:48
Jimmanuel3-Mar-09 3:48 
AnswerRe: Blocking TCP/IP Client Server Pin
mcldev10-Mar-09 10:57
mcldev10-Mar-09 10:57 
QuestionClient Server Comm Pin
mrithula82-Mar-09 17:45
mrithula82-Mar-09 17:45 
//This is the server code im using
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
public class UdpServer
{
    public static void Main()
    {try
        {
            int recv;
            byte[] data = new byte[1024];
            IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);
Socket newsock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            newsock.Bind(ipep);
            Console.WriteLine("Waiting for a client...");            
            IPEndPoint sender = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);
            EndPoint tmpRemote = (EndPoint)(sender);
            recv = newsock.ReceiveFrom(data, ref tmpRemote);
            Console.WriteLine("Message received from {0}:", tmpRemote.ToString());
            Console.WriteLine(Encoding.ASCII.GetString(data, 0, recv));
            data = new byte[1024];
            string ss = "Welcome to the Server";
            data = Encoding.ASCII.GetBytes(ss);
            newsock.SendTo(data, data.Length, SocketFlags.None, tmpRemote);
            Console.WriteLine("\nSent Acknowledgement");
           // newsock.Close();           
        }
        catch (Exception e)
        {
            Console.WriteLine("Error..... " + e.StackTrace);
        }
       // Console.ReadLine();      
    }
}

//This is the client code which im calling inside a button click event
private void Send_Click(object sender, EventArgs e)
       {
           Callback();}
       private void Callback()
       {try
           {
               byte[] data = new byte[1024];
               listBox3.Items.Add("Connecting....");
               IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);
      Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
               listBox3.Items.Add("Connected");
               data = Encoding.ASCII.GetBytes("hello");
               listBox3.Items.Add("Transmitting...");
               server.SendTo(data, data.Length, SocketFlags.None, ipep);//sent hello
               listBox3.Items.Add("Sent...");
     IPEndPoint sender = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);
               EndPoint tmpRemote = (EndPoint)sender;
               listBox3.Items.Add("Message received from {0}:");
               listBox3.Items.Add(tmpRemote.ToString());
               data = new byte[1024];
               int recv = server.ReceiveFrom(data, ref tmpRemote);
               listBox3.Items.Add(Encoding.ASCII.GetString(data,0,recv));
               //listBox3.Items.Add("Stopping client");
               //server.Close();}
           catch (Exception e)
           {
               Console.WriteLine("Error..... " + e.StackTrace);
           }
           Console.ReadLine();}


When i run this code:
My form design is as follows:
With a button click i list the drives in the system,then with another button click i list the folders in each drive,and then listing the exe files in the folder..I have set a default path say C:\projects\ports.The ports folders in turn contains many folders like 10000,10001 etc..I have copied the exe file obtained when compiling the Server Application to 10000...So with a button click event i will get the exe of the server application which should act as server and i have defined the client in the Form1.cs..Now when i have another button click the message(which i have defined inside the code)should be sent to the exe(i.e.server) opened...Please check my code and tell me whether i should make any changes.
Right now when i run this application the exe(server)window closes when i click "Send" button to send the message to the exe...Please help me with this
QuestionPathGradientBrush - blending multiple colors in an ellipse shape Pin
Richard Blythe2-Mar-09 17:15
Richard Blythe2-Mar-09 17:15 
AnswerRe: PathGradientBrush - blending multiple colors in an ellipse shape Pin
Xmen Real 2-Mar-09 20:23
professional Xmen Real 2-Mar-09 20:23 
GeneralRe: PathGradientBrush - blending multiple colors in an ellipse shape Pin
Richard Blythe3-Mar-09 5:00
Richard Blythe3-Mar-09 5:00 
GeneralRe: PathGradientBrush - blending multiple colors in an ellipse shape Pin
Xmen Real 3-Mar-09 5:04
professional Xmen Real 3-Mar-09 5:04 
GeneralRe: PathGradientBrush - blending multiple colors in an ellipse shape Pin
Richard Blythe3-Mar-09 5:15
Richard Blythe3-Mar-09 5:15 
Questionserver Pin
mrithula82-Mar-09 17:08
mrithula82-Mar-09 17:08 
AnswerRe: server Pin
JoseMenendez2-Mar-09 17:13
JoseMenendez2-Mar-09 17:13 
QuestionClient-Server Pin
mrithula82-Mar-09 17:07
mrithula82-Mar-09 17:07 
QuestionFiniding the name of Opened windows which is on task bar Pin
Lijo Rajan2-Mar-09 16:50
Lijo Rajan2-Mar-09 16:50 
AnswerRe: Finiding the name of Opened windows which is on task bar Pin
ABitSmart2-Mar-09 17:13
ABitSmart2-Mar-09 17:13 
GeneralRe: Finiding the name of Opened windows which is on task bar Pin
Lijo Rajan2-Mar-09 17:24
Lijo Rajan2-Mar-09 17:24 
GeneralRe: Finiding the name of Opened windows which is on task bar Pin
ABitSmart2-Mar-09 17:41
ABitSmart2-Mar-09 17:41 
QuestionCustom Label OnPaint Override Issue Pin
Member 3966782-Mar-09 16:44
Member 3966782-Mar-09 16:44 
AnswerRe: Custom Label OnPaint Override Issue Pin
Richard Blythe2-Mar-09 17:06
Richard Blythe2-Mar-09 17:06 
GeneralRe: Custom Label OnPaint Override Issue Pin
Member 3966782-Mar-09 17:55
Member 3966782-Mar-09 17:55 
GeneralRe: Custom Label OnPaint Override Issue Pin
Henry Minute3-Mar-09 6:34
Henry Minute3-Mar-09 6:34 
Questionauto scroll in text box Pin
prasadbuddhika2-Mar-09 16:18
prasadbuddhika2-Mar-09 16:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.