gomaldev

package module
v0.0.0-...-ae08ddd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2024 License: MIT Imports: 5 Imported by: 0

README

GoMalDev

Overview

GoMalDev is a Go package that provides functions to connect to a server, receive messages from the server, send messages to the server, and get information about the number of CPUs.

Installation

To install GoMalDev, run the following command:

go get github.com/user/gomalde

Usage

To use GoMalDev, import the package into your Go program:

import "github.com/user/gomalde"
Connecting to a Server

The Conectar_c function connects to a server at the specified IP address and port. The function will continue to try to connect until it is successful.

func Conectar_c(IP string, PORT int) {
    for i := 0; i == 0; {
        var err error
        conn, err = net.Dial("tcp", fmt.Sprintf("%s:%d", IP, PORT))
        if err != nil {
            i = 0
        }
        i = 1
    }
}
Receiving Messages from the Server

The Receptor_msg_c function receives messages from the server. The function reads up to 4096 bytes from the server and returns the message as a string.

func Receptor_msg_c() string {
    buffer := make([]byte, 4096)
    lector, err := conn.Read(buffer)
    if err != nil {
        msg := fmt.Sprintf("Error: %s", err)
        return msg
    }
    SALIDA := string(buffer[:lector])
    return SALIDA
}
Sending Messages to the Server

The Enviar_msg_c function sends messages to the server. The function writes the message to the server and returns a boolean indicating whether the message was sent successfully.

func Enviar_msg_c(msg string) bool {
    _, err := conn.Write([]byte(msg))
    return err == nil
}
Getting Information about the Number of CPUs

The NucleoInfo function gets information about the number of CPUs. The function returns the number of CPUs as a string.

func NucleoInfo() string {
    NCpu := runtime.NumCPU()
    fmt.print(NCpu)

Comment and Documentacion Generated by BlackboxAI

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Listener net.Listener
)

Functions

func Aceptar_Mensaje

func Aceptar_Mensaje() string

RECIVIR MENSAJES

func Aceptar_cliente

func Aceptar_cliente()

func Conectar_c

func Conectar_c(IP string, PORT int)

function to connect to the server

func Enviar_Mensaje

func Enviar_Mensaje(Mensaje string)

ENVIAR MENSAJES

func Enviar_msg_c

func Enviar_msg_c(msg string) bool

Function to send messages to the server

func GetINF

func GetINF() string

Function to get information about the number of CPUs and the operating system

func GetPathActual

func GetPathActual() string

Get the current working directory

func Moberse_a_una_carpeta

func Moberse_a_una_carpeta(Carpeta string) string

Se mueve a una carpeta Disponibe en la Ruta Actual

func Receptor_msg_c

func Receptor_msg_c() string

Function to read data from the server and return it as a string

func RetrocederPath

func RetrocederPath() string

Retrocede una Carpeta en el Path y devuelve la Ruta de la salida

func StartServerTCP

func StartServerTCP(PORT int)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL