Создать ответ 
 
Рейтинг темы:
  • Голосов: 0 - Средняя оценка: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Modem using post to an API!
Автор Сообщение
NeoSnk Не на форуме
Новичок
*

Сообщений: 8
Зарегистрирован: 29.06.2016
Рейтинг: 0
Сказал спасибо: 7
Поблагодарили 0 раз(а) в 0 сообщ.
Сообщение: #4
RE: Modem using post to an API!
(03.03.2021 14:58)megavolt85 писал(а):  
Код:
#include <stdio.h>
#include <kos/dbglog.h>

#include <arch/arch.h>

#include <ppp/ppp.h>
#include <kos/net.h>

KOS_INIT_FLAGS(INIT_DEFAULT | INIT_NET);

int main(int argc, char *argv[])
{
    int i,conn_rate = 0;
    
    ppp_init();
    
    i = ppp_modem_init("11111", 0, &conn_rate);
    
    if(i < 0)
        return 0;
    
    ppp_set_login("dream", "dreamcast");
    i = ppp_connect();
    
    if(i < 0)
    {
        printf("Link establishment failed!\n");
        return 0;
    }
    
    printf("Link established, rate is %d bps\n", conn_rate);
    
    printf("Pinging the other side of the link (%d.%d.%d.%d)\n",
    net_default_dev->gateway[0], net_default_dev->gateway[1],
    net_default_dev->gateway[2], net_default_dev->gateway[3]);

    for(i = 0; i < 10; ++i)
    {
        net_icmp_send_echo(net_default_dev, net_default_dev->gateway, 1234, i, NULL, 0);
        thd_sleep(500);
    }

    printf("Pinging sylverant.net (138.197.20.130)\n");
    
    for(i = 0; i < 10; ++i)
    {
        uint8 addr[4] = { 138, 197, 20, 130 };
        net_icmp_send_echo(net_default_dev, addr, 1234, i, NULL, 0);
        thd_sleep(500);
    }

    ppp_shutdown();
    
    return 0;
}

Код:
--
KallistiOS ##version##:
  Пн дек 14 04:23:24 MSK 2020
  megavolt@megavolt85:/home/megavolt/dreamcast/kos
maple: active drivers:
    Dreameye (Camera): Camera
    Sound Input Peripheral: Microphone
    PuruPuru (Vibration) Pack: JumpPack
    VMU Driver: Clock, LCD, MemoryCard
    Mouse Driver: Mouse
    Keyboard Driver: Keyboard
    Controller Driver: Controller
    Lightgun: LightGun
  DMA Buffer at ac0ad800
vid_set_mode: 640x480 VGA
dc-load console support enabled
maple: attached devices:
  A0: Dreamcast Controller          (01000000: Controller)
  A1: Visual Memory                 (0e000000: Clock, LCD, MemoryCard)
lan_adapter: no device detected (wrong type = 0)
net_dev_init: detected 0 usable network device(s)
ppp_modem: connected at 33600 bps
ppp: entering phase Establish
lcp: Peer configure request received with opts:
    peer accm: 00000000
    peer magic: 6126407b
    protocol compression on
    addr/ctrl compression on
lcp: received configure ack
ppp: entering phase Network
ipcp: Peer configure request received with opts:
    unknown option: 2 (len 6)
    peer IP: 192.168.1.99
ipcp: peer sent configure nak with opts:
    our IP: 192.168.1.98
    DNS 1: 192.168.1.99
ipcp: Peer configure request received with opts:
    peer IP: 192.168.1.99
ppp: dropping packet with bad final fcs, got: 9b0b
ppp: was for proto 8021
ppp: was 20 bytes long
ipcp: Peer configure request received with opts:
    unknown option: 2 (len 6)
    peer IP: 192.168.1.99
ipcp: received configure ack
ipcp: Peer configure request received with opts:
    peer IP: 192.168.1.99
ppp: entering phase Network
Link established, rate is 33600 bps
Pinging the other side of the link (192.168.1.99)
16 bytes from 192.168.1.99: icmp_seq=0 ttl=64 time=88.415 ms
16 bytes from 192.168.1.99: icmp_seq=1 ttl=64 time=87.220 ms
16 bytes from 192.168.1.99: icmp_seq=2 ttl=64 time=89.613 ms
16 bytes from 192.168.1.99: icmp_seq=3 ttl=64 time=89.520 ms
16 bytes from 192.168.1.99: icmp_seq=4 ttl=64 time=88.099 ms
16 bytes from 192.168.1.99: icmp_seq=5 ttl=64 time=87.663 ms
16 bytes from 192.168.1.99: icmp_seq=6 ttl=64 time=86.339 ms
16 bytes from 192.168.1.99: icmp_seq=7 ttl=64 time=89.626 ms
16 bytes from 192.168.1.99: icmp_seq=8 ttl=64 time=88.878 ms
16 bytes from 192.168.1.99: icmp_seq=9 ttl=64 time=87.884 ms
Pinging sylverant.net (138.197.20.130)
16 bytes from 138.197.20.130: icmp_seq=0 ttl=52 time=230.623 ms
16 bytes from 138.197.20.130: icmp_seq=1 ttl=52 time=224.942 ms
16 bytes from 138.197.20.130: icmp_seq=2 ttl=52 time=222.708 ms
16 bytes from 138.197.20.130: icmp_seq=3 ttl=52 time=228.495 ms
16 bytes from 138.197.20.130: icmp_seq=4 ttl=52 time=224.635 ms
16 bytes from 138.197.20.130: icmp_seq=5 ttl=52 time=230.281 ms
16 bytes from 138.197.20.130: icmp_seq=6 ttl=52 time=240.357 ms
16 bytes from 138.197.20.130: icmp_seq=7 ttl=52 time=226.467 ms
16 bytes from 138.197.20.130: icmp_seq=8 ttl=52 time=219.864 ms
16 bytes from 138.197.20.130: icmp_seq=9 ttl=52 time=226.144 ms
arch: shutting down kernel
net_unreg_device: 'bba' isn't registered
maple: final stats -- device count = 2, vbl_cntr = 3208, dma_cntr = 3191
vid_set_mode: 640x480 VGA

use DNS for ping

Код:
#include <stdio.h>
#include <string.h>

#include <netdb.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>

#include <kos/net.h>
#include <kos/dbgio.h>
#include <arch/arch.h>
#include <ppp/ppp.h>

KOS_INIT_FLAGS(INIT_DEFAULT | INIT_NET);

int main(int argc, char *argv[])
{
    int i,conn_rate = 0;
    struct addrinfo *ai;
    struct addrinfo hints;
    int err;
    
    
    ppp_init();
    
    i = ppp_modem_init("11111", 0, &conn_rate);
    
    if(i < 0)
        return 0;
    
    ppp_set_login("dream", "dreamcast");
    i = ppp_connect();
    
    if(i < 0)
    {
        printf("Link establishment failed!\n");
        return 0;
    }
    
    printf("Link established, rate is %d bps\n", conn_rate);
    
    printf("Looking up IPv4 address of sylverant.net\n");
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_INET;

    if((err = getaddrinfo("sylverant.net", NULL, &hints, &ai))) {
        printf("Error looking up IPv4 address information: %d\n", err);
        ppp_shutdown();
    
        return 0;
    }
    
    printf("Ping sylverant.net\n");
    
    uint8_t addr[4];
    
    for (i = 0; i < 4; i++)
    {
        addr[i] = ((struct sockaddr_in *)ai->ai_addr)->sin_addr.s_addr >> (i*8);
    }
    
    for(i = 0; i < 10; ++i)
    {
        net_icmp_send_echo(net_default_dev, addr, 1234, i, NULL, 0);
        thd_sleep(500);
    }
    
    freeaddrinfo(ai);
    ppp_shutdown();
    
    return 0;
}

Thanks a lot Megavolt85, is it possible to ping a URL and send some parameters to a post method?

I want to make a online ranking, so the URL would receive something like:

http://www.mygame.com?name="dreamcast"&score="1000"

I'm going to try to do a post using pure C++ anyway.

(02.03.2021 23:02)NeoSnk писал(а):  Hello guys, I want to do a test with the Dreamcast Modem. I learned about the BlueCrab ppp.h in KallistiOS, and I'm able to make the Modem Dial and also ping an IP. I'd like to know if it is possible to ping a PHP URL using the post method where I'm going to send some parameters, example:

http://www.mytext.com?name=dreamcast&age=21

I'm using this code:

#include <stdio.h>
#include <kos/dbglog.h>

#include <arch/arch.h>

#include <ppp/ppp.h>
#include <kos/net.h>

KOS_INIT_FLAGS(INIT_DEFAULT | INIT_NET);

int main(int argc, char *argv[]) {
int i;

ppp_init();

i = ppp_modem_init("12", 1, NULL);
if(i < 0)
return 0;

ppp_set_login("dream", "cast");
i = ppp_connect();

if(i == -1) {
printf("Link establishment failed!\n");
return 0;
}

printf("Pinging the other side of the link (%d.%d.%d.%d)\n",
net_default_dev->gateway[0], net_default_dev->gateway[1],
net_default_dev->gateway[2], net_default_dev->gateway[3]);

for(i = 0; i < 10; ++i) {
net_icmp_send_echo(net_default_dev, net_default_dev->gateway, 1234, i,
NULL, 0);
thd_sleep(500);
}

printf("Pinging sylverant.net (67.222.144.120)\n");
for(i = 0; i < 10; ++i) {
uint8 addr[4] = { 67, 222, 144, 120 };
net_icmp_send_echo(net_default_dev, addr, 1234, i, NULL, 0);
thd_sleep(500);
}

ppp_shutdown();
return 0;
}

I tried to created a method: https://stackoverflow.com/questions/2207...e-response

But I didn't get it working. Any input or directions would be welcome, thanks a lot.

I'm going to try with the MegaVolt Code and I'll get a log. thanks.
(Последний раз сообщение было отредактировано 03.03.2021 в 16:19, отредактировал пользователь NeoSnk.)
03.03.2021 16:18
Найти все сообщения Цитировать это сообщение
Создать ответ 


Сообщения в этой теме
Modem using post to an API! - NeoSnk - 02.03.2021, 23:02
RE: Modem using post to an API! - NeoSnk - 03.03.2021 16:18

Похожие темы
Тема: Автор Ответов: Просмотров: Посл. сообщение
  USB Modem Voltage Inducer for Dreamcast aldair 0 6187 08.01.2020 19:12
Посл. сообщение: aldair
  My very first post. Turbokat 2 11015 29.04.2017 14:09
Посл. сообщение: Turbokat
  My first forum post tossEAC 4 18255 03.04.2017 00:33
Посл. сообщение: tossEAC
  Dreamcast DC-PC (FAX MODEM USB): 4X4 Evolution online 100% aldair 0 7843 27.08.2015 20:04
Посл. сообщение: aldair
  Moband Adapter ( Dreamcast modem broadband replacement band ) aldair 1 14575 24.05.2014 21:21
Посл. сообщение: cybdyn
  Connecting to the Internet via USB Modem Dreamcast in emulating win98 win7 aldair 0 7464 16.10.2013 16:55
Посл. сообщение: aldair

Переход:


Пользователи просматривают эту тему: 5 Гость(ей)