<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Nichtaufgeloestes externes Symbol _closesocket@4]]></title><description><![CDATA[<pre><code class="language-cpp">// sockettest.cpp : Definiert den Einsprungpunkt für die Konsolenanwendung.
//

#include &quot;stdafx.h&quot;
#include &lt;iostream.h&gt;
#include &lt;time.h&gt;
#include &lt;winsock.h&gt;

void main(int argc, char *argv[])
{
    time_t t;
    int s;
    struct sockaddr_in a;
    struct hostent *h;
    WSADATA wsaData;

    if (argc != 2)
    {
        cout &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0] &lt;&lt; &quot; host\n&quot;;
        exit(1);
    }
    if(WSAStartup(0x101, &amp;wsaData))
    {
        cout &lt;&lt; &quot;Unable to initialize WinSock library.\n&quot;;
        exit(1);
    }
    h = gethostbyname(argv[1]);
    if (h == NULL)
    {
        cout &lt;&lt; &quot;Cannot resolve hostname\n&quot;;
        WSACleanup();
        exit(1);
    }

    a.sin_family = AF_INET;
    a.sin_port = htons(37);
    memcpy(&amp;(a.sin_addr.s_addr), h-&gt;h_addr, sizeof(int));
    s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (s == 0)
    {
        cout &lt;&lt; &quot;Cannot establish connection: &quot;
             &lt;&lt; WSAGetLastError() &lt;&lt; '\n';
        WSACleanup();
        exit(1);
    }
    if (connect(s, (struct sockaddr *)&amp;a, sizeof(a)))
    {
        cout &lt;&lt; &quot;Cannot establish connection: &quot;
             &lt;&lt; WSAGetLastError() &lt;&lt; '\n';
        WSACleanup();
        exit(1);
    }
    if (recv(s, (char *)&amp;t, 4, 0) != 4)
        cout &lt;&lt; &quot;Unable to obtain time.\n&quot;;
    else
    {
        t = ntohl(t) - 2208988800;
        cout &lt;&lt; asctime(localtime(&amp;t));
    }
    closesocket(s);
    WSACleanup();
}
</code></pre>
<pre><code>sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _closesocket@4
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _ntohl@4
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _recv@16
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _connect@12
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _WSAGetLastError@0
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _socket@12
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _htons@4
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _WSACleanup@0
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _gethostbyname@4
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _WSAStartup@8
Debug/sockettest.exe : fatal error LNK1120: 10 unaufgeloeste externe Verweise
Fehler beim Ausführen von link.exe.

sockettest.exe - 11 Fehler, 0 Warnung(en)
</code></pre>
<p>woran kann das liegen? thx</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/182678/nichtaufgeloestes-externes-symbol-_closesocket-4</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 11:45:27 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182678.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 May 2007 04:39:52 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Nichtaufgeloestes externes Symbol _closesocket@4 on Mon, 28 May 2007 04:39:52 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// sockettest.cpp : Definiert den Einsprungpunkt für die Konsolenanwendung.
//

#include &quot;stdafx.h&quot;
#include &lt;iostream.h&gt;
#include &lt;time.h&gt;
#include &lt;winsock.h&gt;

void main(int argc, char *argv[])
{
    time_t t;
    int s;
    struct sockaddr_in a;
    struct hostent *h;
    WSADATA wsaData;

    if (argc != 2)
    {
        cout &lt;&lt; &quot;Usage: &quot; &lt;&lt; argv[0] &lt;&lt; &quot; host\n&quot;;
        exit(1);
    }
    if(WSAStartup(0x101, &amp;wsaData))
    {
        cout &lt;&lt; &quot;Unable to initialize WinSock library.\n&quot;;
        exit(1);
    }
    h = gethostbyname(argv[1]);
    if (h == NULL)
    {
        cout &lt;&lt; &quot;Cannot resolve hostname\n&quot;;
        WSACleanup();
        exit(1);
    }

    a.sin_family = AF_INET;
    a.sin_port = htons(37);
    memcpy(&amp;(a.sin_addr.s_addr), h-&gt;h_addr, sizeof(int));
    s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (s == 0)
    {
        cout &lt;&lt; &quot;Cannot establish connection: &quot;
             &lt;&lt; WSAGetLastError() &lt;&lt; '\n';
        WSACleanup();
        exit(1);
    }
    if (connect(s, (struct sockaddr *)&amp;a, sizeof(a)))
    {
        cout &lt;&lt; &quot;Cannot establish connection: &quot;
             &lt;&lt; WSAGetLastError() &lt;&lt; '\n';
        WSACleanup();
        exit(1);
    }
    if (recv(s, (char *)&amp;t, 4, 0) != 4)
        cout &lt;&lt; &quot;Unable to obtain time.\n&quot;;
    else
    {
        t = ntohl(t) - 2208988800;
        cout &lt;&lt; asctime(localtime(&amp;t));
    }
    closesocket(s);
    WSACleanup();
}
</code></pre>
<pre><code>sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _closesocket@4
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _ntohl@4
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _recv@16
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _connect@12
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _WSAGetLastError@0
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _socket@12
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _htons@4
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _WSACleanup@0
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _gethostbyname@4
sockettest.obj : error LNK2001: Nichtaufgeloestes externes Symbol _WSAStartup@8
Debug/sockettest.exe : fatal error LNK1120: 10 unaufgeloeste externe Verweise
Fehler beim Ausführen von link.exe.

sockettest.exe - 11 Fehler, 0 Warnung(en)
</code></pre>
<p>woran kann das liegen? thx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293451</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293451</guid><dc:creator><![CDATA[pixartist]]></dc:creator><pubDate>Mon, 28 May 2007 04:39:52 GMT</pubDate></item><item><title><![CDATA[Reply to Nichtaufgeloestes externes Symbol _closesocket@4 on Mon, 28 May 2007 04:48:07 GMT]]></title><description><![CDATA[<p>pixartist schrieb:</p>
<blockquote>
<p>woran kann das liegen? thx</p>
</blockquote>
<p>Daran, dass du Ws2_32.lib nicht zu deinem Programm gelinkt hast. Dass du das tun must, steht übrigens in der Dokumentation jeder dieser Funktionen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1293452</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1293452</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Mon, 28 May 2007 04:48:07 GMT</pubDate></item></channel></rss>