Programming/golang2025. 2. 18. 14:27

리눅스에서 일반실행파일을 systemctl에 등록해서 실행하는것과 다르게

윈도우에서는 윈도우 서비스 api를 통해서 구동을 해야 정상적으로 구동된다.

 

일반적인 네트워크 echo 프로그램을 빌드해서 실행해보니

서비스 등록 문제 없음

서비스 실행 -> 실행중 -> 중지됨 으로 어느정도 시간이 지난후 멈춰버린다.

[링크 : https://pkg.go.dev/golang.org/x/sys/windows/svc]

 

[링크 : http://golang.site/go/article/116-윈도우즈-서비스-프로그램]

[링크 : http://www.toughman.pe.kr/2020/09/gogolang-언어로-윈도우즈-서비스-프로그램-만들기/]

'Programming > golang' 카테고리의 다른 글

golang tcp socket timeout 주기(listen, read)  (0) 2024.04.08
golang reflect  (0) 2024.02.20
golang echo i18n  (0) 2024.02.19
golang package  (0) 2024.02.19
golang html/template ParseFiles()  (0) 2024.02.16
Posted by 구차니
Microsoft/Windows2025. 2. 18. 12:01

심심해서(?) go로 작성한 echo 서버를 크로스빌드하고 서비스 등록했는데

"시작중"이 뜨다가 "종료됨"으로 떠버린다.

프로그램이 서비스로 작동하기 위해서는 일반적인 프로그램을 실행하면 안되는건가 싶기도 한데..

 

빌드는 아래와 같이 하고

$ go mod ninit
$ go mod init echo
$ go mod tidy
$ GOOS=windows go build

[링크 : https://github.com/venilnoronha/tcp-echo-server]

[링크 : https://dadev.tistory.com/entry/GO-Windows-macOS-및-Linux용-Go-프로그램을-교차-컴파일하는-방법]

 

한번 그냥 실행해서 방화벽 예외 추가해주고, 관리자 권한의 콘솔에서 아래와 같이 입력해주면 끝

C:\Windows\system32>sc create "echo service" binPath= "c:\echo\echo.exe 9000 hello"
[SC] CreateService 성공

C:\Windows\system32>sc delete "echo service"
[SC] DeleteService 성공

[링크 : https://blog.naver.com/battle50/220311915822]

 

특이하게도 옵션 이름에 =가 붙어야 해서 =" 하면 안된다.

C:\Windows\system32>sc create "echo service" binPath ="c:\echo\echo.exe 9000 hello"
설명:
        레지스트리 및 서비스 데이터베이스에 서비스 항목을 만듭니다.
사용법:
        sc <서버>create [서비스 이름] [binPath= ] <옵션1> <옵션2>...

옵션:
참고: 옵션 이름은 등호(=)를 포함합니다.
      등호와 값 사이에는 공백이 한 칸 있어야 합니다.
 type= <own|share|interact|kernel|filesys|rec|userown|usershare>
       (default = own)
 start= <boot|system|auto|demand|disabled|delayed-auto>
       (default = demand)
 error= <normal|severe|critical|ignore>
       (default = normal)
 binPath= <.exe 파일에 대한 BinaryPathName>
 group= <LoadOrderGroup>
 tag= <yes|no>
 depend= <종속성(슬래시(/)로 구분)>
 obj= <AccountName|ObjectName>
       (default = LocalSystem)
 DisplayName= <표시 이름>
 password= <암호>

 

테스트는 리눅스에서 아래와 같이 테스트 하면 끝. telnet에서 ctrl-c,d,z를 다 패스시키니

ctrl-[ 를 이용해서 메뉴로 나와 종료해야 한다.

$ telnet 192.168.220.253 9000
Trying 192.168.220.253...
Connected to 192.168.220.253.
Escape character is '^]'.

hello 
d
hello d
^]
telnet> quit
Connection closed.

[링크 : https://superuser.com/questions/486496/how-do-i-exit-telnet]

Posted by 구차니

공식 다운로드는 아래인데

[링크 : https://mosquitto.org/download/]

 

받아도 방화벽 설정은 하나도 안되고 내부에서만 허용되는 설정으로 설치가 된다.

그러니 외부 접속이 필요하면 아래 내용을 참고하여 인바운드 1883/tcp를 허용해주어야 한다.

[링크 : https://velog.io/@foxiq/MQTT-사용]

 

윈도우 64bit로 설치했을 경우 C:\Program Files\mosquitto\mosquitto.conf 에 설정 파일이 저장된다.

굳이 listener 1883 0.0.0.0 으로 해주진 않아도 외부 접속을 허용하게 되는 것으로 보인다.

# =================================================================
# Listeners
# =================================================================

# Listen on a port/ip address combination. By using this variable
# multiple times, mosquitto can listen on more than one port. If
# this variable is used and neither bind_address nor port given,
# then the default listener will not be started.
# The port number to listen on must be given. Optionally, an ip
# address or host name may be supplied as a second argument. In
# this case, mosquitto will attempt to bind the listener to that
# address and so restrict access to the associated network and
# interface. By default, mosquitto will listen on all interfaces.
# Note that for a websockets listener it is not possible to bind to a host
# name.
#
# On systems that support Unix Domain Sockets, it is also possible
# to create a # Unix socket rather than opening a TCP socket. In
# this case, the port number should be set to 0 and a unix socket
# path must be provided, e.g.
# listener 0 /tmp/mosquitto.sock
#
# listener port-number [ip address/host name/unix socket path]
#listener
listener 1883
allow_anonymous true

 

+

2025.02.21

포트를 바꿀 경우 -p 로 바꾸어 주고

다른 서버일 경우 -h ip를 추가해주면 된다.

C:\Program Files\mosquitto>mosquitto_sub -p 27839 -t topic -u username -P password

 

C:\Program Files\mosquitto>mosquitto_pub  -p 27839 -t MY -u username -P password -m asdf

+

 

allow_anonymous true가 없으면 아래 에러가 발생한다.

Connection error: Connection Refused: not authorised.

 

전체 테스트 과정은 아래와 같다.

윈도우 (서버) 다른 PC/linux (클라이언트)
1. 프로그램 설치  
2. 방화벽 설정  
3. conf 파일 수정 및 서비스 재기동  
4. client 접속
C:\Program Files\mosquitto>mosquitto_sub.exe -t MY_TOPIC
4. client 접속
$ mosquitto_sub -v -h 192.168.0.11 -t MY_TOPIC
5. publish
C:\Program Files\mosquitto>mosquitto_pub.exe -t MY_TOPIC -m HELLO
 
  6. 메시지 확인
HELLO

-v 시에는
MY_TOPIC HELLO

 

---

Just edit Mosquitto configuration file ( /etc/mosquitto/conf.d/mosquitto.conf ) adding these lines...
allow_anonymous true
listener 1883 0.0.0.0

[링크 : https://stackoverflow.com/questions/24556160/mosquitto-client-obtain-refused-connection]

[링크 : https://iotmaker.kr/2021/08/23/mosquitto-remote-access-for-windows/]

[링크 : https://blog.naver.com/loyz/222654739136]

[링크 : https://pros2.tistory.com/137]

'프로그램 사용 > mosquitto' 카테고리의 다른 글

mosquitto qos  (0) 2025.04.18
mosquitto for windows 계정추가  (0) 2025.02.18
CC2531 zigbee - mqtt  (0) 2025.01.07
ubuntu MQTT(mosquito)  (0) 2024.05.23
mosquitto - MQTT broker  (0) 2019.05.15
Posted by 구차니

언제 샀었는지도 기억이 안나고 기록도 조회가 안되는 녀석이 있는데

아내가 S22로 가면서 3.5 파이가 없는데 차에는 블루투스가 없어서

예전에 어마어마한 노이즈 때문에 포기했던걸 다시 연결해봄

 

머.. 소리가 안나면 삐~ 소리가 나서 거슬리지만

음악 나는 동안엔 뭍히니 어떻게 쓸만은 할텐데

블루투스 장치가 좋아야 노이즈가 안탈까..

시가잭 충전기를 좋은걸 사야 노이즈가 안탈까?

[링크 : https://m.blog.naver.com/willytheguy/222733610180]

 

고속도로 휴게소 가보니

USB DAC 포함된 USB-C to 3.5로도 많이 판매하긴 하던데.. 그게 나으려나?

'개소리 왈왈 > 모바일 생활' 카테고리의 다른 글

별 거 아닌데 수상하네  (2) 2025.05.22
삼성 dex 4k로 출력하기  (6) 2025.02.03
핸드폰 공기계 구매, 교체  (2) 2025.02.02
내 핸드폰.. 슬슬 한계?  (0) 2025.01.13
스팀덱 지름병  (0) 2024.12.18
Posted by 구차니
개소리 왈왈/컴퓨터2025. 2. 17. 22:13

음.. 갤럭시 노트 펜으로 안되려나?

 

인튜어스2? GD-0608

6.1.6 ~ 6.1.7

[링크 : https://puum.tistory.com/118]

인튜어스 3? PTZ-630

6.3.15-3

[링크 : https://support.wacom.com/hc/ko/articles/1500006341302-Intuos-3-PTZ-모델-타블렛의-드라이버는-무엇입니까]

 

 

 

 

 

gimp 에서 하려니 왜 안뜰까??

[링크 : https://www.youtube.com/watch?v=J198Mx75pJE]

 

[링크 : https://greenon.tistory.com/316]

'개소리 왈왈 > 컴퓨터' 카테고리의 다른 글

mx4 4g 써멀 지름  (0) 2025.02.24
10g 또 지름  (0) 2025.02.20
줍줍 7세대?  (0) 2025.02.11
10g nic 지름  (0) 2025.02.10
레노버 보증조회 그리고 fan error?  (0) 2025.02.09
Posted by 구차니

계획하지 않았지만 어쩌다 보니 가보고 싶었던 곳을 한 큐에 가버린 느낌

부산대교 - 아침에 산책하다 여기 건너고 싶다!
부산항대교 - 이름은 몰랐지만 그 미친(?) 회전 상승 진입로(!!)
광안대교 - 이름은 몰랐지만 먼가 어마어마한(!) 다리

 

아무튼 오전 11시에 숙소에서 나와서

국제시장에서 2시 쯤 밥 먹고 나와서

해운대 들렀다가 3시 쯤 출발해서 집에 오니 10시 20분

어우.. 빡세 -_ㅠ

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

컴백  (0) 2025.03.02
피곤하다 -_ㅠ  (0) 2025.03.01
부산 도착  (0) 2025.02.15
기절  (0) 2025.02.08
ko  (0) 2025.02.05
Posted by 구차니

어우 멀다.

원래는 세종시 들러서 오려고 했는데

1시간 차이나는데다가, 방문하고 시간 끌면 거의 6시간이 넘어서

애들도 나도 지칠것 같아 그냥 목적지 까지 휴게소만 들르고 달려옴

날씨가 조금 우중충 하지만 그래도 먼가 새로운 곳에서의 새로운 느낌이라

아내가 좋아하는 듯.

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

피곤하다 -_ㅠ  (0) 2025.03.01
해운대  (0) 2025.02.16
기절  (0) 2025.02.08
ko  (0) 2025.02.05
옥송이  (0) 2025.01.28
Posted by 구차니
프로그램 사용/iperf2025. 2. 15. 13:23

iperf3 자체에서는  jumbo packet을 설정하는게 아니라

ifconfig를 통해 jumbo packet 크기로 MTU를 설정하면 된다.(1500 이상)

[링크 : http://www.packetinside.com/2012/03/jumbo-frame.html]

 

'프로그램 사용 > iperf' 카테고리의 다른 글

iperf 파일로 바로바로 떨궈서 tail로 보기  (0) 2025.02.10
iperf3  (0) 2023.07.28
iperf udp 테스트  (0) 2022.03.14
iperf로 100M 랜 / IEEE1394 대역폭 측정  (2) 2011.12.07
iperf - 대역폭 측정  (0) 2009.10.22
Posted by 구차니

회사에서 RFID 카드 읽을일이 있어서 해보려는데 재료(?)가 없어서 구매!

회사에 올리면 귀찮으니 걍 지름!

 

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

"smart card resource manager is not running"  (0) 2025.02.18
acr1252u 스마트 카드 리더  (0) 2025.02.18
libpcsclite 라이브러리  (0) 2025.02.14
rfid, smart card reader  (0) 2025.02.12
ubunut smart card 읽기  (0) 2025.02.12
Posted by 구차니

pcsc_scan 프로그램에서 정체를(?) 알 수 없는 함수들이 있어서 찾아보는데

libpcsclite 쪽 거였다. 별다르게 include 하는 것도 없어 보였는데 wincard.h 가 그거였던 듯..

그나저나 이름이나 변수타입 등등 윈도우 버전을 거의 그대로 옮긴 느낌이 강하네..

 

API 목록

$ readelf -a libpcsclite.so.1.0.0
The decoding of unwind sections for machine type AArch64 is not currently supported.

Symbol table '.dynsym' contains 77 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000001638     0 SECTION LOCAL  DEFAULT   10 .init
     2: 000000000001b000     0 SECTION LOCAL  DEFAULT   22 .data
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy@GLIBC_2.17 (2)
     4: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strlen@GLIBC_2.17 (2)
     5: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_deregisterT[...]
     6: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND _[...]@GLIBC_2.17 (2)
     7: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
     8: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND stderr@GLIBC_2.17 (2)
     9: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND kill@GLIBC_2.17 (2)
    10: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fileno@GLIBC_2.17 (2)
    11: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    12: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    13: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    14: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND time@GLIBC_2.17 (2)
    15: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND malloc@GLIBC_2.17 (2)
    16: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND open@GLIBC_2.17 (2)
    17: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND poll@GLIBC_2.17 (2)
    18: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    19: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memset@GLIBC_2.17 (2)
    20: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND g[...]@GLIBC_2.17 (2)
    21: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    22: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND s[...]@GLIBC_2.17 (2)
    23: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND rand@GLIBC_2.17 (2)
    24: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strdup@GLIBC_2.17 (2)
    25: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND s[...]@GLIBC_2.17 (2)
    26: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    27: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    28: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND close@GLIBC_2.17 (2)
    29: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
    30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND stat@GLIBC_2.33 (3)
    31: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (4)
    32: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    33: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcmp@GLIBC_2.17 (2)
    34: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strtol@GLIBC_2.17 (2)
    35: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND free@GLIBC_2.17 (2)
    36: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND n[...]@GLIBC_2.17 (2)
    37: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND send@GLIBC_2.17 (2)
    38: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND c[...]@GLIBC_2.17 (2)
    39: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.34 (5)
    40: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fcntl@GLIBC_2.17 (2)
    41: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND socket@GLIBC_2.17 (2)
    42: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    43: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strcpy@GLIBC_2.17 (2)
    44: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND read@GLIBC_2.17 (2)
    45: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND isatty@GLIBC_2.17 (2)
    46: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND srand@GLIBC_2.17 (2)
    47: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND s[...]@GLIBC_2.17 (2)
    48: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_registerTMC[...]
    49: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _[...]@GLIBC_2.17 (2)
    50: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getenv@GLIBC_2.17 (2)
    51: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    52: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.17 (2)
    53: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.34 (5)
    54: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND p[...]@GLIBC_2.34 (5)
    55: 0000000000004170   196 FUNC    GLOBAL DEFAULT   12 SCardGetAttrib
    56: 0000000000004990   324 FUNC    GLOBAL DEFAULT   12 SCardCancel
    57: 0000000000004ad4   160 FUNC    GLOBAL DEFAULT   12 SCardIsValidContext
    58: 00000000000027a0   608 FUNC    GLOBAL DEFAULT   12 SCardConnect
    59: 0000000000003f90   472 FUNC    GLOBAL DEFAULT   12 SCardControl
    60: 0000000000004234    80 FUNC    GLOBAL DEFAULT   12 SCardSetAttrib
    61: 0000000000002db0   416 FUNC    GLOBAL DEFAULT   12 SCardBeginTransaction
    62: 0000000000003094  1168 FUNC    GLOBAL DEFAULT   12 SCardStatus
    63: 0000000000008478    16 OBJECT  GLOBAL DEFAULT   14 g_rgSCardT0Pci
    64: 0000000000002a00   488 FUNC    GLOBAL DEFAULT   12 SCardReconnect
    65: 0000000000004560   548 FUNC    GLOBAL DEFAULT   12 SCardListReaders
    66: 0000000000008458    16 OBJECT  GLOBAL DEFAULT   14 g_rgSCardRawPci
    67: 0000000000004834   348 FUNC    GLOBAL DEFAULT   12 SCardListReaderGroups
    68: 0000000000002bf0   448 FUNC    GLOBAL DEFAULT   12 SCardDisconnect
    69: 0000000000003524  2668 FUNC    GLOBAL DEFAULT   12 SCardGetStatusChange
    70: 0000000000004784   176 FUNC    GLOBAL DEFAULT   12 SCardFreeMemory
    71: 0000000000002540   600 FUNC    GLOBAL DEFAULT   12 SCardReleaseContext
    72: 0000000000008468    16 OBJECT  GLOBAL DEFAULT   14 g_rgSCardT1Pci
    73: 0000000000004284   724 FUNC    GLOBAL DEFAULT   12 SCardTransmit
    74: 0000000000001d40   832 FUNC    GLOBAL DEFAULT   12 pcsc_stringify_error
    75: 0000000000004c30  1120 FUNC    GLOBAL DEFAULT   12 SCardEstablishContext
    76: 0000000000002f50   324 FUNC    GLOBAL DEFAULT   12 SCardEndTransaction

[링크 : https://pcsclite.apdu.fr/api/group__API.html]

 

+

리더기에 다이렉트로 붙이려면 SCARD_SHARE_DIRECT로 해서 명령을 보내라는데...

(난 카드의 시리얼을 받고 싶었고, 이 글은 리더기의 시리얼을 받고 싶어하고)

You should be using:

lReturn = SCardConnect(hResManager,szAvailRdr,SCARD_SHARE_SHARED,
                            SCARD_PROTOCOL_T1,
                            &hCardHandle,
                            &dwActProtocol);
Instead, try using:

lReturn = SCardConnect(hResManager,szAvailRdr,SCARD_SHARE_DIRECT,
                      NULL,
                      &hCardHandle,
                      NULL);
where szAvailRdr refers to the reader name (smartcard readername) and hCardHandle is a handle obtained before using scardconnect.

This should keep you going!

[링크 : https://stackoverflow.com/questions/6940824/getting-pcsc-reader-serial-number-with-winscard]

 

sector / block 개념으로 1k 데이터를 쓸수 있다고.

그러면 serial은 어디서 빼내지?

[링크 : https://you-rang.tistory.com/243]

[링크 : https://blog.naver.com/intopion/221613937290]

'하드웨어 > rfid_nfc_smartcard' 카테고리의 다른 글

acr1252u 스마트 카드 리더  (0) 2025.02.18
아내 몰래(?) 회사 몰래 지르기  (0) 2025.02.14
rfid, smart card reader  (0) 2025.02.12
ubunut smart card 읽기  (0) 2025.02.12
ATR (Answer To Reset)  (0) 2025.02.12
Posted by 구차니