If I use the "getservbyname", I can correctly assign my Winsock port to SMTP:
ServEntry = getservbyname("smtp", "tcp");
if (ServEntry != NULL)
sin.sin_port = ServEntry->s_port;
If I want to set this port to a different port number, how do I set it? I have a situation where a the SMTP port is different (for security purposes), and I need to use a variable:
sin.sin_port = SMTPPort;
Do I need to use htons(SMTPPort)? Will there be conversion problems for sin_port because it's a 16bit field, or do I just typecast it to fix the compile error?