Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. server connect

server connect

Scheduled Pinned Locked Moved C#
csharpgraphicssysadmindocker
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    heba abu ghaleih22
    wrote on last edited by
    #1

    hi this code server

    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.Net;
    using System.Net.Sockets;
    using System.Text;

    namespace Asynchronous_Server
    {
    /// /// Summary description for Form1.
    ///
    public class Form1 : System.Windows.Forms.Form
    {
    Socket server = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);
    IPEndPoint iep = new IPEndPoint(IPAddress.Any, 5020);
    private byte[] data = new byte[1024];
    private int size = 1024;
    private System.Windows.Forms.TextBox conStatus;
    private System.Windows.Forms.ListBox results;
    /// /// Required designer variable.
    ///
    private System.ComponentModel.Container components = null;

    	public Form1()
    	{
    		//
    		// Required for Windows Form Designer support
    		//
    		InitializeComponent();
    
    		//
    		// TODO: Add any constructor code after InitializeComponent call
    		//
    
    	}
    
    	/// /// Clean up any resources being used.
    	/// 
    	protected override void Dispose( bool disposing )
    	{
    		if( disposing )
    		{
    			if (components != null) 
    			{
    				components.Dispose();
    			}
    		}
    		base.Dispose( disposing );
    	}
    
    	#region Windows Form Designer generated code
    	/// /// Required method for Designer support - do not modify
    	/// the contents of this method with the code editor.
    	/// 
    	private void InitializeComponent()
    	{
            this.results = new System.Windows.Forms.ListBox();
            this.conStatus = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // results
            // 
            this.results.BackColor = System.Drawing.Color.AliceBlue;
            this.results.Dock = System.Windows.Forms.DockStyle.Fill;
            this.results.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(178)));
            this.results.Items.AddRange(new object\[\] {
            "Clients Transmissions ..."});
            this.results.Location = new System.Drawing.Point(0, 0);
            this.results.Name = "results";
            this.results.Size = new System.Drawing.Size(288, 174);
            this.results.TabIndex = 0;
            this.results.SelectedIndexChanged += new System.EventHandler(this.results\_SelectedIndexChanged);
    
    Richard Andrew x64R 1 Reply Last reply
    0
    • H heba abu ghaleih22

      hi this code server

      using System;
      using System.Drawing;
      using System.Collections;
      using System.ComponentModel;
      using System.Windows.Forms;
      using System.Data;
      using System.Net;
      using System.Net.Sockets;
      using System.Text;

      namespace Asynchronous_Server
      {
      /// /// Summary description for Form1.
      ///
      public class Form1 : System.Windows.Forms.Form
      {
      Socket server = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);
      IPEndPoint iep = new IPEndPoint(IPAddress.Any, 5020);
      private byte[] data = new byte[1024];
      private int size = 1024;
      private System.Windows.Forms.TextBox conStatus;
      private System.Windows.Forms.ListBox results;
      /// /// Required designer variable.
      ///
      private System.ComponentModel.Container components = null;

      	public Form1()
      	{
      		//
      		// Required for Windows Form Designer support
      		//
      		InitializeComponent();
      
      		//
      		// TODO: Add any constructor code after InitializeComponent call
      		//
      
      	}
      
      	/// /// Clean up any resources being used.
      	/// 
      	protected override void Dispose( bool disposing )
      	{
      		if( disposing )
      		{
      			if (components != null) 
      			{
      				components.Dispose();
      			}
      		}
      		base.Dispose( disposing );
      	}
      
      	#region Windows Form Designer generated code
      	/// /// Required method for Designer support - do not modify
      	/// the contents of this method with the code editor.
      	/// 
      	private void InitializeComponent()
      	{
              this.results = new System.Windows.Forms.ListBox();
              this.conStatus = new System.Windows.Forms.TextBox();
              this.SuspendLayout();
              // 
              // results
              // 
              this.results.BackColor = System.Drawing.Color.AliceBlue;
              this.results.Dock = System.Windows.Forms.DockStyle.Fill;
              this.results.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(178)));
              this.results.Items.AddRange(new object\[\] {
              "Clients Transmissions ..."});
              this.results.Location = new System.Drawing.Point(0, 0);
              this.results.Name = "results";
              this.results.Size = new System.Drawing.Size(288, 174);
              this.results.TabIndex = 0;
              this.results.SelectedIndexChanged += new System.EventHandler(this.results\_SelectedIndexChanged);
      
      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      You didn't say what error it gives.

      The difficult we do right away... ...the impossible takes slightly longer.

      H 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        You didn't say what error it gives.

        The difficult we do right away... ...the impossible takes slightly longer.

        H Offline
        H Offline
        heba abu ghaleih22
        wrote on last edited by
        #3

        when do connect error in this line

        conStatus.Text = "Connected to: " + client.RemoteEndPoint.ToString();
        
        Richard Andrew x64R 1 Reply Last reply
        0
        • H heba abu ghaleih22

          when do connect error in this line

          conStatus.Text = "Connected to: " + client.RemoteEndPoint.ToString();
          
          Richard Andrew x64R Offline
          Richard Andrew x64R Offline
          Richard Andrew x64
          wrote on last edited by
          #4

          Yeah, what is the error message?

          The difficult we do right away... ...the impossible takes slightly longer.

          H 1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            Yeah, what is the error message?

            The difficult we do right away... ...the impossible takes slightly longer.

            H Offline
            H Offline
            heba abu ghaleih22
            wrote on last edited by
            #5

            Cross-thread operation not valid: Control 'conStatus' accessed from a thread other than the thread it was created on.

            Richard Andrew x64R 1 Reply Last reply
            0
            • H heba abu ghaleih22

              Cross-thread operation not valid: Control 'conStatus' accessed from a thread other than the thread it was created on.

              Richard Andrew x64R Offline
              Richard Andrew x64R Offline
              Richard Andrew x64
              wrote on last edited by
              #6

              This gives the solution: Cross Thread Calls[^]

              The difficult we do right away... ...the impossible takes slightly longer.

              H 1 Reply Last reply
              0
              • Richard Andrew x64R Richard Andrew x64

                This gives the solution: Cross Thread Calls[^]

                The difficult we do right away... ...the impossible takes slightly longer.

                H Offline
                H Offline
                heba abu ghaleih22
                wrote on last edited by
                #7

                thnx :)

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups