Skip to content
DEV.XFOR.TOP DEV.XFOR.TOP
  • PHP
  • JS
  • Go
  • CSS
  • xHTML
  • Noty

Метка: ws

Создание вебсокета на GO

17.11.202010.11.2020 Golang #ws on Создание вебсокета на GO
package main

import (
	"io"
	"net/http"

	"golang.org/x/net/websocket"
)

func echoHandler(ws *websocket.Conn) {
	io.Copy(ws, ws)
}

func main() {
	http.Handle("/echo", websocket.Handler(echoHandler))
	http.Handle("/", http.FileServer(http.Dir(".")))
	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		panic("ListenAndServe: " + err.Error())
	}
}
Contacts
  • Email: dev@xfor.top
  • Telegram: @xfortop1
  • Github: utz0r2
E-commerce Scripts
  • Витрина vvStore
  • Магазин vvShop
  • Магазин Lashop
Категории
  • PHP
  • JS
  • Go
  • CSS
  • Заметки
Поиск
xfor.top © 2008 – 2022
Прокрутка вверх