Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7871897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:03:02+00:00 2026-06-03T02:03:02+00:00

Using a typical irc client I can type in: /server localhost 6667 nick:pass When

  • 0

Using a typical irc client I can type in:

/server localhost 6667 nick:pass

When I enter the nick:pass I configured for ZNC,(an IRC bouncer) I’m forwarded to the server that znc is connected to under my server/nick:pass combination.

How can I programmatically open a winsock connection with all of these arguments simultaneously? /server localhost 6667 nick:pass

I’ve tried sending the data after connecting but znc seems to be ignoring the requests. Or I’m just not connecting to it at all. This code has connected to an IRC server that doesn’t require Ping authentication, so I know it works.

#define AF_INET                    2
#define SOCK_STREAM                1
#define SOL_SOCKET                 0xffff
#define SO_SNDTIMEO                0x1005

string server_addr = "127.0.0.1";
int server_port = 6667;

void ircconnect(){
int struct_sockaddr[4];
int addr, port_low, port_high;
int opts[1];
int c;

if (irc_disabled == 1) return(0);

// fill the sockaddr struct
addr = inet_addr(server_addr);
port_low = server_port & 0x00ff;
port_high = (server_port & 0xff00) >> 8; 
struct_sockaddr[0] = AF_INET | (port_high << 16) | (port_low << 24);
struct_sockaddr[1] = addr;
struct_sockaddr[2] = 0;
struct_sockaddr[3] = 0;

// connect
s = socket(AF_INET, SOCK_STREAM, 0);

opts[0] = 1000; // send timeout milliseconds
setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, opts, 4);
c = connect(s, struct_sockaddr, 16);

Sleep(5000);

sendLine(nick + ":" + password);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:03:02+00:00Added an answer on June 3, 2026 at 2:03 am

    See the python explanation below:

    int struct_sockaddr[4];
    int addr, port_low, port_high;
    int opts[1];
    int c;
    string zncauth = nick + ":" + password;
    
    if (irc_disabled == 1) return(0);
    
    // fill the sockaddr struct
    addr = inet_addr(server_addr);
    port_low = server_port & 0x00ff;
    port_high = (server_port & 0xff00) >> 8; 
    struct_sockaddr[0] = AF_INET | (port_high << 16) | (port_low << 24);
    struct_sockaddr[1] = addr;
    struct_sockaddr[2] = 0;
    struct_sockaddr[3] = 0;
    
    // connect
    s = socket(AF_INET, SOCK_STREAM, 0);
    opts[0] = 1000; // send timeout milliseconds
    setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, opts, 4);
    c = connect(s, struct_sockaddr, 16);
    
    // send
    sendLine("NICK zncbotnick");
    sendLine("USER znc bot znc :znc");
    sendLine("PASS " + zncauth);
    
    void sendLine(string text){
        if (irc_disabled == 1) return(0);
        text = text + "\r\n";
        send(s, text, StringLen(text), 0);
    }
    

    The code above finally works and this works for me in python to authenticate with ZNC. Basically, in the other language I was throwing commands to znc but they never got to znc because the code was missing return and newline characters '\r\n'. With python, I was able to diagnose the problem in real-time.

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    
    //Test.py
    import socket
    
    zncauth = 'nick:password'
    server_addr = '127.0.0.1'
    server_port = 6667
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.connect((server_addr, server_port))   
    s.send( 'NICK botnick\r\n')
    s.send( 'USER znc bot znc :znc\r\n')
    s.send( 'PASS ' + zncauth + ' \r\n')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On a typical OS how many files can i have opened at once using
When communicating to a SQL Server database using one of the typical systems, ODBC,
Consider this typical disconnected scenario: load a Customer object from SQL Server using LINQ
I am using Websphere Application Server to create a typical web application where UI
Using the typical SQLiteDatabase object in Android's API, what can I do to get
I've got a typical webform that submits using the ajax module. How can I
Can a typical Lisp dialect solve problems using the bottom-up dynamic programming approach? (Please
Im using a typical situation with UINavigationController, id like to make the navigation bar
I am using the typical validator controls for required fields etc. On this form,
I am able to send emails using the typical C# SMTP code across Exchange

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.