Tcp/ip Sockets In C#

Status
Niet open voor verdere reacties.

erikiej1

Gebruiker
Lid geworden
29 apr 2008
Berichten
138
Ik heb laatst een boek gekocht want ik wil Sockets leren te gebruiken.
In dat boek staan wat voorbeelden. 1 ervan:

Code:
using System;
using System.Net;
using System.Net.Sockets;

class IPAddressExample {
      static void PrintHostInfo(String host){
             try{
                 IPHostEntry hostInfo;
                 
                 hostInfo = Dns.Resolve(host);
                 
                 Console.WriteLine("\tCanonical Name: " + hostInfo.HostName);
                 
                 Console.Write("\tIP Addresses:   ");
                 
                 foreach (IPAddress ipaddr int hostInfo.AddressList){
                         Console.Write(ipaddr.ToString()+" ");
                 }
                 Console.WriteLine();
                 
                 Console.Write("\tAliases:       ");
                 foreach(String alias in hostInfo.Aliases){
                                Console.Write(alias + " ");
                 }
                 Console.WriteLine("\n");
             } catch(Exception) {
                                Console.WriteLine("\tUnable to resolve host: " + host + "\n");
             }
      }
      
      static void main(string[] args ){
             try{
                 Console.WriteLine("Local Host:");
                 String localHostName = Dns.GetHostName();
                 Console.WriteLine("\tHost Name:     " + localHostName);
                 
                 PrintHostInfo(localHostName);
             }catch (Exception) {
                    Console.WriteLine("Unable to resolve local host\n");
             }
             
             foreach(String arg in args) {
                            Console.WriteLine(arg + ":");
                            PrintHostInfo(arg);
             }
      }
}

Hoe kan ik die compileren? Ik ben het meest Dev-C++ gewend, Maar die geeft een error:

[Build Error] Naamvanbestand.o Error 1

Hulp zou fijn zijn :rolleyes:
 
Je wil dus een C#.net programma in een C++ compiler compilen?
Dat gaat je niet echt lukken ;)
Wat je zou kunnen gebruiken om een c# programma te 'builden´ is bijvoorbeeld Microsoft Visual Studio
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan