What is the .net equivelent of the java URL and HttpUrlConnection Classes

i am making a browser. i want to add a feature that will allow me to view the source. i know how to do this in java using the URL, and HttpUrlConnection classes
.NEt ≠ С++.
Search some .Net related forums instead.
really then explain this code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#using <System.dll>

using namespace System;
using namespace System::IO::Ports;
using namespace System::Threading;

public ref class PortChat
{
private:
    static bool _continue;
    static SerialPort^ _serialPort;

public:
    static void Main()
    {
        String^ name;
        String^ message;
        StringComparer^ stringComparer = StringComparer::OrdinalIgnoreCase;
        Thread^ readThread = gcnew Thread(gcnew ThreadStart(PortChat::Read));

        // Create a new SerialPort object with default settings.
        _serialPort = gcnew SerialPort();

        // Allow the user to set the appropriate properties.
        _serialPort->PortName = SetPortName(_serialPort->PortName);
        _serialPort->BaudRate = SetPortBaudRate(_serialPort->BaudRate);
        _serialPort->Parity = SetPortParity(_serialPort->Parity);
        _serialPort->DataBits = SetPortDataBits(_serialPort->DataBits);
        _serialPort->StopBits = SetPortStopBits(_serialPort->StopBits);
        _serialPort->Handshake = SetPortHandshake(_serialPort->Handshake);

        // Set the read/write timeouts
        _serialPort->ReadTimeout = 500;
        _serialPort->WriteTimeout = 500;

        _serialPort->Open();
        _continue = true;
        readThread->Start();

        Console::Write("Name: ");
        name = Console::ReadLine();

        Console::WriteLine("Type QUIT to exit");

        while (_continue)
        {
            message = Console::ReadLine();

            if (stringComparer->Equals("quit", message))
            {
                _continue = false;
            }
            else
            {
                _serialPort->WriteLine(
                    String::Format("<{0}>: {1}", name, message) );
            }
        }

        readThread->Join();
        _serialPort->Close();
    }

    static void Read()
    {
        while (_continue)
        {
            try
            {
                String^ message = _serialPort->ReadLine();
                Console::WriteLine(message);
            }
            catch (TimeoutException ^) { }
        }
    }

    static String^ SetPortName(String^ defaultPortName)
    {
        String^ portName;

        Console::WriteLine("Available Ports:");
        for each (String^ s in SerialPort::GetPortNames())
        {
            Console::WriteLine("   {0}", s);
        }

        Console::Write("COM port({0}): ", defaultPortName);
        portName = Console::ReadLine();

        if (portName == "")
        {
            portName = defaultPortName;
        }
        return portName;
    }

    static Int32 SetPortBaudRate(Int32 defaultPortBaudRate)
    {
        String^ baudRate;

        Console::Write("Baud Rate({0}): ", defaultPortBaudRate);
        baudRate = Console::ReadLine();

        if (baudRate == "")
        {
            baudRate = defaultPortBaudRate.ToString();
        }

        return Int32::Parse(baudRate);
    }

    static Parity SetPortParity(Parity defaultPortParity)
    {
        String^ parity;

        Console::WriteLine("Available Parity options:");
        for each (String^ s in Enum::GetNames(Parity::typeid))
        {
            Console::WriteLine("   {0}", s);
        }

        Console::Write("Parity({0}):", defaultPortParity.ToString());
        parity = Console::ReadLine();

        if (parity == "")
        {
            parity = defaultPortParity.ToString();
        }

        return (Parity)Enum::Parse(Parity::typeid, parity);
    }

    static Int32 SetPortDataBits(Int32 defaultPortDataBits)
    {
        String^ dataBits;

        Console::Write("Data Bits({0}): ", defaultPortDataBits);
        dataBits = Console::ReadLine();

        if (dataBits == "")
        {
            dataBits = defaultPortDataBits.ToString();
        }

        return Int32::Parse(dataBits);
    }

    static StopBits SetPortStopBits(StopBits defaultPortStopBits)
    {
        String^ stopBits;

        Console::WriteLine("Available Stop Bits options:");
        for each (String^ s in Enum::GetNames(StopBits::typeid))
        {
            Console::WriteLine("   {0}", s);
        }

        Console::Write("Stop Bits({0}):", defaultPortStopBits.ToString());
        stopBits = Console::ReadLine();

        if (stopBits == "")
        {
            stopBits = defaultPortStopBits.ToString();
        }

        return (StopBits)Enum::Parse(StopBits::typeid, stopBits);
    }

    static Handshake SetPortHandshake(Handshake defaultPortHandshake)
    {
        String^ handshake;

        Console::WriteLine("Available Handshake options:");
        for each (String^ s in Enum::GetNames(Handshake::typeid))
        {
            Console::WriteLine("   {0}", s);
        }

        Console::Write("Handshake({0}):", defaultPortHandshake.ToString());
        handshake = Console::ReadLine();

        if (handshake == "")
        {
            handshake = defaultPortHandshake.ToString();
        }

        return (Handshake)Enum::Parse(Handshake::typeid, handshake);
    }
};

int main()
{
    PortChat::Main();
}


it uses .NET classes
String^ I am seriously interested how is that working.

it uses .NET classes
I can use FORTRAN with C++. Should I ask how to use Fortran modules here?
It's c++/cli, c++ with .net managed extensions.
So It isn't C++.
You can have some luck in windows programing, I think I have seen some .Net experts here.
Last edited on
Considering this is in the lounge, I am now going to veer slightly off topic:
I can use FORTRAN with C++

How? It sounds interesting.
http://www.yolinux.com/TUTORIALS/LinuxTutorialMixingFortranAndC.html
Also there is some tools (more like preprocessors, they separate C and Fortran code compile it separatly and handle connections) with which you can have both C and Fortran code in one file (uses FORTRAN{} like asm{} insertions)
They are used in some research institutes where there is loads of legacy code which nobody bothers to rewrite and also some older researches knows only Fortran :|.

Well I have read my posts and they looks rude. Everything I wanted to convey is that you can get more help in specialised forums instead in general one. .NET isn't C++ specific and you actually get more info on it on C# forums, even if you going to use in with C++ based language.
Last edited on
@MiiNiPaa thank you, I heard there is even a modern Fortran.
.NET isn't C++ specific and you actually get more info on it on C# forums, even if you going to use in with C++ based language.
Agreed. The fact that .NET is essentially C#'s standard library you're going to find a lot more people experienced with it in a C# forum. Try StackOverflow.
I can use FORTRAN with C++. Should I ask how to use Fortran modules here?


you treat .NET like it is a language
Last edited on
Ok. code you posted is not C++.
You cannot have ^ after type name in C++. public ref class is not valid either. No C++ standard compliant compiler will compile your code even if you provide headers and libraries. What you posted essentually is another language. Wikipedia seems to agree with me:
C++/CLI should be thought of as a language of its own
http://en.wikipedia.org/wiki/C%2B%2B/CLI
I repeat what I said again: Even if there is some people with good knowledge of .Net, you will find more qualified help on specialised forums. MSDN for example.
Script Coder wrote:
I heard there is even a modern Fortran.

Fortran is currently defined by the 2010 standard (called "Fortran-2008"), that's almost as recent as C++11. (I mix C++ with Fortran often, too)
C++/CLI is an extension of C++, it is another language:
http://www.ecma-international.org/publications/standards/Ecma-372.htm

-----===##===-----
you treat .NET like it is a language

So what is .net?

A whole host of technologies bundled together under this neat little term '.net'.
Common Language Runtime (CLR)
Common Type System (CTS)
Common Language Infrastructure (CLI)
Base Class Library (BCL)
Framework Class Library (FCL)
Common Intermediate Language (CIL)
...

.net has specifications for what a .net language has to do. C++/CLI is a .net language i.e. it is designed to produce CLI assemblies. C++ is not a .net language.

Topic archived. No new replies allowed.