<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Approximatrix Forums — Fortran TCP/IP sockets]]></title>
	<link rel="self" href="https://forums.approximatrix.com/extern.php?action=feed&amp;tid=771&amp;type=atom" />
	<updated>2020-09-18T12:31:38Z</updated>
	<generator>PunBB</generator>
	<id>https://forums.approximatrix.com/viewtopic.php?id=771</id>
		<entry>
			<title type="html"><![CDATA[Re: Fortran TCP/IP sockets]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3586#p3586" />
			<content type="html"><![CDATA[<p>Pete,</p><p>If you want to use SSL as well, you need to add these flags to the Linker box in Compiler Flags:<br /></p><div class="codebox"><pre><code>-lssl -lcrypto -lws2_32 -lcrypt32</code></pre></div><p>You might also need to tell the compiler where these libraries are unless you extracted that distribution of OpenSSL directly in your project directory.&nbsp; You&#039;ll need to add them using the <a href="http://simplyfortran.com/docs/full/windows/options/project.html">File Locations section in Project Options</a>.</p><p>If you&#039;re just experimenting with sockets, though, you might want to stay away from SSL.&nbsp; It simply adds another layer of complexity that you probably don&#039;t need right now.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2020-09-18T12:31:38Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3586#p3586</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Fortran TCP/IP sockets]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3583#p3583" />
			<content type="html"><![CDATA[<p>Hi Jeff,<br />That worked great but it brought another raft of problems in the linking. In your example files there was a &quot;use jessl&quot; statement. I found jessl and included it in my little test piece but it refers to a lot of SSL functions. Thinking they were useful too, I downloaded the SSL library that you recommended in that project. Now the issue I have is (of course) undefined references to the SSL functions and I don&#039;t know how to link the SSL library into my program. I looked in the documentation,but it&#039;s not covered. I&#039;m sorry to keep asking newbie questions, but in all my Fortran work, I have never had to link to an external library of any sort and it&#039;s a mystery to me. Can you help with this too? Or maybe point me towards doumentation that I may have overlooked?<br />Regards,<br />Pete</p>]]></content>
			<author>
				<name><![CDATA[peter.kelly]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3586</uri>
			</author>
			<updated>2020-09-18T06:55:50Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3583#p3583</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Fortran TCP/IP sockets]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3582#p3582" />
			<content type="html"><![CDATA[<p>Yes, you need to link with the Windows Sockets library.&nbsp; In Project Options, you would have to add the following:<br /></p><div class="codebox"><pre><code>-lws2_32</code></pre></div><p>to the Linker box under &quot;Compiler Flags&quot; to use sockets.&nbsp; This library is included in our distribution.</p><p>Also, make sure, on Windows, that you call <em>WSAStartup</em> very early in your program or all your socket operations will fail.&nbsp; This function is Windows-specific, but everything else that was network-related in the linked project is completely portable to Linux, macOS, BSD, etc.&nbsp; My wrapper for <em>WSAStartup</em> is in <a href="http://git.rainbow-100.com/cgit.cgi/LR-87/tree/wsa.f90">wsa.f90</a>.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2020-09-17T12:04:26Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3582#p3582</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Fortran TCP/IP sockets]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3581#p3581" />
			<content type="html"><![CDATA[<p>Hi Jeff.<br />Thank you for replying so quickly. The code that you posted was very helpful in understanding the area. However, when I put it together to simply test if I could open a socket, I got linker errors for the underlying C functions ie &quot;undefined reference to `socket&#039; &quot;.<br />I can easily see the bindings from Fortran to the underlying C functions in the code but I seem to be missing the C functions. Is there another library that I need to link it? (If so, how?) I&#039;ve poured over the whole project but can&#039;t see anything. <br />Regards,<br />Peter</p>]]></content>
			<author>
				<name><![CDATA[peter.kelly]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3586</uri>
			</author>
			<updated>2020-09-17T03:12:41Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3581#p3581</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Fortran TCP/IP sockets]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3580#p3580" />
			<content type="html"><![CDATA[<p>Using the older library almost certainly won&#039;t work with Simply Fortran.&nbsp; As an exercise, though, I&#039;ve written a browser in pure Fortran for the <a href="https://gemini.circumlunar.space/">Gemini protocol</a>, a sort of simpler-than-the-web Internet experience.&nbsp; In doing so, I wrote a pretty minimal socket interface that works on Windows and Linux, shown here in <a href="http://git.rainbow-100.com/cgit.cgi/LR-87/tree/network.F90">network.F90</a> that wraps socket functions in Fortran.&nbsp; Windows has the added step of <a href="http://git.rainbow-100.com/cgit.cgi/LR-87/tree/wsa.f90">initializing any application that will use TCP/IP</a>, so be careful.</p><p>The sockets are then used pretty much as you would in C.&nbsp; In that project, the <em>open_connection</em> function in <a href="http://git.rainbow-100.com/cgit.cgi/LR-87/tree/request.f90">request.f90</a> shows how the socket would be handled at a low level.</p><p>Hopefully some of this is helpful.</p>]]></content>
			<author>
				<name><![CDATA[jeff]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=2</uri>
			</author>
			<updated>2020-09-15T12:33:36Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3580#p3580</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Fortran TCP/IP sockets]]></title>
			<link rel="alternate" href="https://forums.approximatrix.com/viewtopic.php?pid=3579#p3579" />
			<content type="html"><![CDATA[<p>Hi There!<br />I wanted to write a pair of Fortran programs that would communicate to each other over a Network. As such, I had a good look around the internet but couldn&#039;t find much at all. Do you know of a Fortran Sockets implementation? <br />Further to that, I did find an antique Intel Fortran implementation of a baby sized &quot;Proof of Concept&quot; Fortran program that used Sockets. However, it depends on the Visual Studio library &quot;Wininit.lib&quot; to define the sockets etc.&nbsp; I did get my hands on a copy of the *.lib file, but I have no idea how to link it it. Can you help me with that too?<br />Any help is really appreciated. <br />Regards,<br />Pete</p>]]></content>
			<author>
				<name><![CDATA[peter.kelly]]></name>
				<uri>https://forums.approximatrix.com/profile.php?id=3586</uri>
			</author>
			<updated>2020-09-15T08:58:06Z</updated>
			<id>https://forums.approximatrix.com/viewtopic.php?pid=3579#p3579</id>
		</entry>
</feed>
