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 8623183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:13:26+00:00 2026-06-12T07:13:26+00:00

I am having trouble with this error I am receiving whenever I run my

  • 0

I am having trouble with this error I am receiving whenever I run my application. The error is:
loop or previous error loading module 'socket'.

The code that is causing this error is:
socket = require("socket").

This error occurs during the first lua_pcall. Here is the function that calls that:

void startTerminal(int port, char host[80])
{
    lua_State *L = lua_open();

    /* Open Lua Library */
    luaL_openlibs(L);

    /* Choose the lua file that will run */
    if(luaL_loadfile(L, "socket.lua")) {
        lfatal(L, "luaL_loadfile() failed");
    }

    /* Start lua file */
    if(lua_pcall(L, 0, 0, 0)) {
        lfatal(L, "lua_pcall()");
    }

    /* Get connect function */
    lua_getglobal(L, "connect");

    if(!lua_isfunction(L, -1)) {
        lua_pop(L, 1);
        lfatal(L, "lua_isfunction() failed");
    }

    /* Setup arguments */
    lua_pushnumber(L, port);
    lua_pushstring(L, host);

    /* Call the lua function */
    if(lua_pcall(L, 2, 2, 0)) {
        lfatal(L, "lua_pcall() failed");
    }

    /* Print out results */
    printf("%s", lua_tostring(L, -1));
    printf("%s", lua_tostring(L, -1));

    lua_close(L);
}

Here is how I am compiling the code:

gcc -Wall -o terminal attacker.c -I/usr/include/lua5.1 -llua5.1 -lm

Am I missing any switches during compile or am I missing library?

NOTE:
The compiler does not throw any errors and compiles cleanly.
In other Lua applications that does not include C, I don’t have any problem with require("socket").

Thanks

  • 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-12T07:13:27+00:00Added an answer on June 12, 2026 at 7:13 am
    luaL_loadfile(L, "socket.lua")
    

    This is suspect. Very suspect.

    Using the standard Lua loaders, when you issue require("MODULE_NAME"), the very first thing it will look for (after checking to see if MODULE_NAME was already loaded) will be “MODULE_NAME.lua”. In the current directory. Which certainly exists. It’s called socket.lua, the very file you’ve loaded and are trying to execute. Therefore, it’s going to try to load socket.lua as a module.

    And since socket.lua has require("socket") in it, it will load itself again. And again. And again.

    Well, it won’t because Lua’s package loader system is smart enough to detect loops and issue an error. Which is exactly what it did.

    So don’t name a file MODULE_NAME.lua if you actually are going to require a module with that name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having an error in my C++ application that I am having trouble
I'm having trouble finding the error in the following code: #include <stdio.h> #define LOOP
I'm having trouble compiling some C code. When I compile, I'l get this error:
I'm having trouble overriding a ModelForm save method. This is the error I'm receiving:
I am having trouble with this error message as the line it errors on
I am having trouble storing a numpy csr_matrix with PyTables. I'm getting this error:
I'm having trouble using variables in my SQL WHERE clause. I'm getting this error:
I'm having trouble with this PHP script where I get the error Fatal error
I am having trouble moving this JLabel across this JPanel? I put the code
I am having trouble getting this invisibilityOfElementLocated() method to work. Here is the code

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.