<div dir="ltr">The compiler is Visual C++. <div><br></div><div>I'm trying to fix this C code to work in Windows since my app is a Windows service written in Visual C++. It would be be real nice if openSSL had a version</div><div>of the sample program that works in Microsoft Visual C++.</div><div><br></div><div>Anyway, I went to my existing C++ code and found where it creates a socket and the type needs to be SOCKET, not int.</div><div><br></div><div>Still got more to fix. Wish me luck.<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font face="monospace, monospace"><br></font><div><div style="font-size:12.8px"><div style="font-size:12.8px"><font face="monospace, monospace">Don Payette</font></div><div style="font-size:12.8px"><span style="font-family:monospace,monospace;font-size:small">(cell) <a href="tel:(479)%20216-6320" value="+14792166320" style="color:rgb(17,85,204)" target="_blank">479-216-6320</a></span></div></div></div></div></div></div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 24, 2023 at 12:02 PM Michael Wojcik via openssl-users <<a href="mailto:openssl-users@openssl.org">openssl-users@openssl.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> From: Don Payette <<a href="mailto:payettedon@gmail.com" target="_blank">payettedon@gmail.com</a>> <br>
> Sent: Wednesday, 24 May, 2023 10:42<br>
<br>
> Right now I'm attempting to compile sslecho using Microsoft Visual C++.<br>
> It's giving me an error which I can't figure out.<br>
> I'm guessing that this is because it's C++ instead of C.<br>
<br>
I'm not sure what you believe is C++. The code you posted here is C.<br>
<br>
> int create_socket ()<br>
> {<br>
>    int s;<br>
>    int optval = 1;<br>
><br>
>    s = socket (AF_INET, SOCK_STREAM, 0);<br>
>    if (s < 0) {<br>
>        perror("Unable to create socket");<br>
>        exit(EXIT_FAILURE);<br>
>    }<br>
><br>
>    return s;<br>
> }<br>
<br>
This isn't going to work on Windows, where the return type of the socket() function is HANDLE, not int. This code is written to work in a UNIX (SUS, POSIX) environment. As it is, it's not suitable for Windows, unless you're building under a POSIX or POSIX-like environment within Windows such as WSL, MinGW, or Cygwin.<br>
  <br>
...<br>
<br>
>    client_skt = create_socket;<br>
><br>
> Error (active) E0513 a value of type "int (*)()" cannot be assigned to an entity of type "int" OpenSSL-Demo  line 152<br>
<br>
create_socket is a function. This line is not invoking the function; it's trying to assign it to a variable. You can only do that in C if the variable is of a function-pointer type.<br>
<br>
What you want here is:<br>
<br>
   client_skt = create_socket();<br>
<br>
Note the parentheses.<br>
<br>
However, as I pointed out above, this code is unsuitable for Windows anyway, unless you're working in a POSIXy environment.<br>
<br>
-- <br>
Michael Wojcik<br>
</blockquote></div>