ARMmbed / ARMmbed/mbed-example-network

helloworld-tcpclient: Scheduling a second request fails with Socket Error: Null pointer

Open
#49 1 comment 0 reactions 0 assignees View on GitHub
mirrored
Dominant language
C++
Stars
4
Forks
7
PR merge metrics
No merged PRs in 30d

Description

A second request to same url 5 delayed for some time fails:

```
mbed::util::FunctionPointer1 fp(hello, &HelloHTTP::startTest);
minar::Scheduler::postCallback(fp.bind(HTTP_PATH));

// Schedule the same request in 5 seconds.
minar::Scheduler::postCallback(fp.bind(HTTP_PATH)).delay(minar::milliseconds(5000));
```

Output:

```
Hello world!
{{success}}
{{end}} <----- First request succeeds
Starting DNS lookup for developer.mbed.org
MBED: Socket Error: Null pointer (4)
{{failure}}
{{end}}
```

The reason is that the stream is opened in the constructor and closed at the end of the test.
Rather than opening the stream in the HelloWorld constructor it should be opened in the beginning startTest(). ( Or do not close the stream automatically at the end of each test)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.