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
  1. Home
  2. General Programming
  3. C#
  4. Do you think this is stupid ?

Do you think this is stupid ?

Scheduled Pinned Locked Moved C#
csharpsysadmindebugginghelpquestion
9 Posts 3 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.
  • S Offline
    S Offline
    Sharpoverride
    wrote on last edited by
    #1

    Try this peace of code .. instead of giving an error it connects to a ipHostEntry that doesn't exist Can anyone tell me why ? Why me ? Oh .. why ? using System; using System.Net; using System.Net.Sockets; namespace ThisIsStupid { public class MainC { public static void Main() { IPEndPoint ipe = new IPEndPoint( IPAddress.Parse( "193.168.0.6"),21); //System.Diagnostics.Debug.WriteLine( ipadd ); Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); // Console.WriteLine(s.Connected ); s.Connect(ipe ); if( s.Connected ) { Console.WriteLine( " I have a socket that didn't connect to nothing "); Console.WriteLine(" But it's status is connected "); Console.WriteLine(" Uraaa !"); } } } } I've made a client - server aplication and my class informes the main program that the requiered connection exists when no client is available there .. ? Why ... is that correct ... what am I doing rong ? Lazar Mihai Highschool student

    C D 2 Replies Last reply
    0
    • S Sharpoverride

      Try this peace of code .. instead of giving an error it connects to a ipHostEntry that doesn't exist Can anyone tell me why ? Why me ? Oh .. why ? using System; using System.Net; using System.Net.Sockets; namespace ThisIsStupid { public class MainC { public static void Main() { IPEndPoint ipe = new IPEndPoint( IPAddress.Parse( "193.168.0.6"),21); //System.Diagnostics.Debug.WriteLine( ipadd ); Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); // Console.WriteLine(s.Connected ); s.Connect(ipe ); if( s.Connected ) { Console.WriteLine( " I have a socket that didn't connect to nothing "); Console.WriteLine(" But it's status is connected "); Console.WriteLine(" Uraaa !"); } } } } I've made a client - server aplication and my class informes the main program that the requiered connection exists when no client is available there .. ? Why ... is that correct ... what am I doing rong ? Lazar Mihai Highschool student

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Port 21 is the port used by FTP. Do you have an existing FTP server on that machine?


      My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

      S 1 Reply Last reply
      0
      • C Colin Angus Mackay

        Port 21 is the port used by FTP. Do you have an existing FTP server on that machine?


        My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

        S Offline
        S Offline
        Sharpoverride
        wrote on last edited by
        #3

        NO .. I tried with port 7891 and with 4545 .. if you have any other suggestions ... try on you computer you'll get the same result Lazar Mihai Highschool student

        C 1 Reply Last reply
        0
        • S Sharpoverride

          NO .. I tried with port 7891 and with 4545 .. if you have any other suggestions ... try on you computer you'll get the same result Lazar Mihai Highschool student

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          I extended your class so I could see what was happening. When I tried the other ports you mentioned I got an exception to say that it wasn't connected. When I tried port 21 my application returned:

          32 32 30 20 4d 69 63 72 : 220 Micr
          6f 73 6f 66 74 20 46 54 : osof t FT
          50 20 53 65 72 76 69 63 : P Se rvic
          65 d a 0 0 0 0 0 : e

          public class MainC
          {
          	private static byte\[\] buffer = new byte\[1024\];
          	public static void Main()
          	{
          		IPEndPoint ipe = new IPEndPoint( IPAddress.Parse( "127.0.0.1"),21);
          		//System.Diagnostics.Debug.WriteLine( ipadd );
          		Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
          		// Console.WriteLine(s.Connected );
          		s.Connect(ipe );
          
          		if( s.Connected )
          		{
          			Console.WriteLine( " I have a socket that didn't connect to nothing ");
          			Console.WriteLine(" But it's status is connected ");
          			Console.WriteLine(" Uraaa !");
          			
          		}
          		else
          		{
          			Console.WriteLine("Not Connected");
          		}
          
          		int result = s.Receive(buffer, 1024, SocketFlags.Peek);
          		Console.WriteLine("Received {0} bytes", result);
          		for(int i=0; i<result; i+=8)
          		{
          			Console.WriteLine("{0:x} {1:x} {2:x} {3:x}  {4:x} {5:x} {6:x} {7:x} : {8}{9}{10}{11} {12}{13}{14}{15}", 
          				buffer\[i\], buffer\[i+1\], buffer\[i+2\], buffer\[i+3\],
          				buffer\[i+4\], buffer\[i+5\], buffer\[i+6\], buffer\[i+7\],
          				(char)buffer\[i\], (char)buffer\[i+1\], (char)buffer\[i+2\], (char)buffer\[i+3\],
          				(char)buffer\[i+4\], (char)buffer\[i+5\], (char)buffer\[i+6\], (char)buffer\[i+7\]
          				);
          		}
          		Console.ReadLine();
          	}
          

          My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

          S 1 Reply Last reply
          0
          • C Colin Angus Mackay

            I extended your class so I could see what was happening. When I tried the other ports you mentioned I got an exception to say that it wasn't connected. When I tried port 21 my application returned:

            32 32 30 20 4d 69 63 72 : 220 Micr
            6f 73 6f 66 74 20 46 54 : osof t FT
            50 20 53 65 72 76 69 63 : P Se rvic
            65 d a 0 0 0 0 0 : e

            public class MainC
            {
            	private static byte\[\] buffer = new byte\[1024\];
            	public static void Main()
            	{
            		IPEndPoint ipe = new IPEndPoint( IPAddress.Parse( "127.0.0.1"),21);
            		//System.Diagnostics.Debug.WriteLine( ipadd );
            		Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
            		// Console.WriteLine(s.Connected );
            		s.Connect(ipe );
            
            		if( s.Connected )
            		{
            			Console.WriteLine( " I have a socket that didn't connect to nothing ");
            			Console.WriteLine(" But it's status is connected ");
            			Console.WriteLine(" Uraaa !");
            			
            		}
            		else
            		{
            			Console.WriteLine("Not Connected");
            		}
            
            		int result = s.Receive(buffer, 1024, SocketFlags.Peek);
            		Console.WriteLine("Received {0} bytes", result);
            		for(int i=0; i<result; i+=8)
            		{
            			Console.WriteLine("{0:x} {1:x} {2:x} {3:x}  {4:x} {5:x} {6:x} {7:x} : {8}{9}{10}{11} {12}{13}{14}{15}", 
            				buffer\[i\], buffer\[i+1\], buffer\[i+2\], buffer\[i+3\],
            				buffer\[i+4\], buffer\[i+5\], buffer\[i+6\], buffer\[i+7\],
            				(char)buffer\[i\], (char)buffer\[i+1\], (char)buffer\[i+2\], (char)buffer\[i+3\],
            				(char)buffer\[i+4\], (char)buffer\[i+5\], (char)buffer\[i+6\], (char)buffer\[i+7\]
            				);
            		}
            		Console.ReadLine();
            	}
            

            My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

            S Offline
            S Offline
            Sharpoverride
            wrote on last edited by
            #5

            Don't connect to local host ... on local hosts it works ... I want on other ip addresses not to work ... Lazar Mihai Highschool student

            C 1 Reply Last reply
            0
            • S Sharpoverride

              Don't connect to local host ... on local hosts it works ... I want on other ip addresses not to work ... Lazar Mihai Highschool student

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              Sorry, same deal if I use my external IP address. On port 21 I get a message from the FTP service I'm running, and on the other two ports it causes an exception because it cannot connect.


              My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

              S 1 Reply Last reply
              0
              • S Sharpoverride

                Try this peace of code .. instead of giving an error it connects to a ipHostEntry that doesn't exist Can anyone tell me why ? Why me ? Oh .. why ? using System; using System.Net; using System.Net.Sockets; namespace ThisIsStupid { public class MainC { public static void Main() { IPEndPoint ipe = new IPEndPoint( IPAddress.Parse( "193.168.0.6"),21); //System.Diagnostics.Debug.WriteLine( ipadd ); Socket s = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp); // Console.WriteLine(s.Connected ); s.Connect(ipe ); if( s.Connected ) { Console.WriteLine( " I have a socket that didn't connect to nothing "); Console.WriteLine(" But it's status is connected "); Console.WriteLine(" Uraaa !"); } } } } I've made a client - server aplication and my class informes the main program that the requiered connection exists when no client is available there .. ? Why ... is that correct ... what am I doing rong ? Lazar Mihai Highschool student

                D Offline
                D Offline
                Daniel Turini
                wrote on last edited by
                #7

                Try this: telnet 193.168.0.6 21 If telnet connects, this is a valid host/port combination. I see dead pixels Yes, even I am blogging now!

                S 1 Reply Last reply
                0
                • C Colin Angus Mackay

                  Sorry, same deal if I use my external IP address. On port 21 I get a message from the FTP service I'm running, and on the other two ports it causes an exception because it cannot connect.


                  My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

                  S Offline
                  S Offline
                  Sharpoverride
                  wrote on last edited by
                  #8

                  You are right .. thanks I think I 've fixed the bug Lazar Mihai Highschool student

                  1 Reply Last reply
                  0
                  • D Daniel Turini

                    Try this: telnet 193.168.0.6 21 If telnet connects, this is a valid host/port combination. I see dead pixels Yes, even I am blogging now!

                    S Offline
                    S Offline
                    Sharpoverride
                    wrote on last edited by
                    #9

                    Cool ... telnet worked .. why if the address doesn't exist on the LAN .. ? Lazar Mihai Highschool student

                    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