Ziky
at the first glance it looks you forgot to add length of body
Ziky
but what about stepping it in debugger?
Ziky
Ya deway
however i have been using wireshark using post requests and the content is not displaying anyway, i have no problem with requests without body, they print fine. requests with a body are the problem, because the body doesn't get printed
Ziky
Ziky
Ziky
click one green button fork this on the top if you wan edit it or debug it
Ziky
because I already commented out the line which was terminating your string at length of your headers by null characters
Ziky
Ziky
aou mast have unterminated custom_head or header_len is too far
Ya deway
The problem I don't understand is that it didn't work even with memcopy() having the exact bytes...(to avoid problems with string terminators etc..) but I did a rigorous check on wireshark and the calculations were correct, I really don't know what be wrong
Ziky
print your inputs before funvtion is called
Ziky
you don't need to let e know. I just don't think to problem is int your function
Ya deway
I'm very doubtful that the problem is outside the function because I have personally compared more than one package with wireshark and all sizes matched, also everything works perfectly if I don't call the function for injection, including print. My personal opinion is that it is a calculation problem within that function, would it be possible? Am I probably missing a few bytes in the calculations?
Ziky
ah mazbe i know :D
Ziky
It depends on encoding, funciton will work properly only on ascii and utf8
Ziky
or to be more correct - any 0 byte will break it
Ya deway
klimi
i can
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
I guys. I have a Client - Server application. This simulates (via UDP socket) the Go-Back-N protocol, so you give a window dimension and it will simulate go back n. The code (both Client and Server) works and does what it is meant to do. The only problem lies in a segmentation fault client-side taking place when I remove fprintf server-side.
Being the biggest challenge, I had to use several fprintf to debug the server. And, as long as those fprintf stay there it's all safe and sound, but the very moment I delete them, client will crash after having recieved some packets. I don't know why it happens, but I had more experienced people check my code and there are no bad accesses nor errors with pointers or malloc. So I don't really know what's happening.
As I said, the code has got no formal error. What I believe, is that the several fprintfs server-side "slow it down" and the client can keep the pace of the transmission. Note: this only happens for very large files. I did some experiments and the client seems to crash at about 15 MB, but I can't be certain of that. I can assure you that the client can download anything under 1 MB at super speed, the problem arises when the file is too big.
Is there any way to solve this? I know it's hard to tell without the code in front of your eyes, but perhaps some of you have experienced the same issue
⚛ Hz
udp is not a "reliable" protocol, are you assuming that each packet is received in the order it was sent (and without any lost)?
Maxim
I guys. I have a Client - Server application. This simulates (via UDP socket) the Go-Back-N protocol, so you give a window dimension and it will simulate go back n. The code (both Client and Server) works and does what it is meant to do. The only problem lies in a segmentation fault client-side taking place when I remove fprintf server-side.
Being the biggest challenge, I had to use several fprintf to debug the server. And, as long as those fprintf stay there it's all safe and sound, but the very moment I delete them, client will crash after having recieved some packets. I don't know why it happens, but I had more experienced people check my code and there are no bad accesses nor errors with pointers or malloc. So I don't really know what's happening.
As I said, the code has got no formal error. What I believe, is that the several fprintfs server-side "slow it down" and the client can keep the pace of the transmission. Note: this only happens for very large files. I did some experiments and the client seems to crash at about 15 MB, but I can't be certain of that. I can assure you that the client can download anything under 1 MB at super speed, the problem arises when the file is too big.
Is there any way to solve this? I know it's hard to tell without the code in front of your eyes, but perhaps some of you have experienced the same issue
Segmentation fault is always about incorrect memory access. Have you tried to run your application under gdb or another debugger? You need to find a place in your code when your application crashes, otherwise there is almost no sense to talk about high level work of your app
Danya🔥
I guys. I have a Client - Server application. This simulates (via UDP socket) the Go-Back-N protocol, so you give a window dimension and it will simulate go back n. The code (both Client and Server) works and does what it is meant to do. The only problem lies in a segmentation fault client-side taking place when I remove fprintf server-side.
Being the biggest challenge, I had to use several fprintf to debug the server. And, as long as those fprintf stay there it's all safe and sound, but the very moment I delete them, client will crash after having recieved some packets. I don't know why it happens, but I had more experienced people check my code and there are no bad accesses nor errors with pointers or malloc. So I don't really know what's happening.
As I said, the code has got no formal error. What I believe, is that the several fprintfs server-side "slow it down" and the client can keep the pace of the transmission. Note: this only happens for very large files. I did some experiments and the client seems to crash at about 15 MB, but I can't be certain of that. I can assure you that the client can download anything under 1 MB at super speed, the problem arises when the file is too big.
Is there any way to solve this? I know it's hard to tell without the code in front of your eyes, but perhaps some of you have experienced the same issue
Based on the information you have provided, it is difficult to determine the exact cause of the segmentation fault without examining your code in detail. However, here are some general suggestions that you can try to solve this issue:
Enable compiler warnings: Enable compiler warnings to check if there are any uninitialized variables or unused variables in your code. Fixing these issues might solve your problem.
Check for memory leaks: Use a tool like Valgrind to check for memory leaks in your code. Memory leaks can cause segmentation faults and can be difficult to debug.
Use a debugger: Use a debugger like gdb to debug your code. You can set breakpoints and step through your code to see where the problem is occurring.
Optimize your code: If your code is running slowly, try to optimize it. Use profiling tools to identify the slow parts of your code and try to optimize them.
Check for buffer overflow: If you are using buffers in your code, check if you are overflowing them. Buffer overflow can cause segmentation faults.
Use defensive programming: Use defensive programming techniques like checking for null pointers and validating input to prevent unexpected behavior.
Use logging instead of fprintf: Instead of using fprintf for debugging, use a logging library like Log4j or Log4cxx. This will help you to log the information you need without affecting the performance of your code.
These are some general suggestions that you can try to solve your problem.
Azri
Hi everyone. I'm trying to self study for C++ programming... Can anyone suggest me a few books that I should read based on your experience and give some advice to be consistent in programming?
Danya🔥
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Danya🔥
Ehsan
Ehsan
I guys. I have a Client - Server application. This simulates (via UDP socket) the Go-Back-N protocol, so you give a window dimension and it will simulate go back n. The code (both Client and Server) works and does what it is meant to do. The only problem lies in a segmentation fault client-side taking place when I remove fprintf server-side.
Being the biggest challenge, I had to use several fprintf to debug the server. And, as long as those fprintf stay there it's all safe and sound, but the very moment I delete them, client will crash after having recieved some packets. I don't know why it happens, but I had more experienced people check my code and there are no bad accesses nor errors with pointers or malloc. So I don't really know what's happening.
As I said, the code has got no formal error. What I believe, is that the several fprintfs server-side "slow it down" and the client can keep the pace of the transmission. Note: this only happens for very large files. I did some experiments and the client seems to crash at about 15 MB, but I can't be certain of that. I can assure you that the client can download anything under 1 MB at super speed, the problem arises when the file is too big.
Is there any way to solve this? I know it's hard to tell without the code in front of your eyes, but perhaps some of you have experienced the same issue
It sounds like you have a complex issue with your Client-Server application. From what you’ve described, it seems that removing the fprintf statements on the server-side causes a segmentation fault on the client-side when transferring large files. It’s possible that the fprintf statements are slowing down the server enough for the client to keep up with the transmission.
One way to approach this issue is to add some debugging statements on the client-side to see where exactly the segmentation fault is occurring. You could also try adding some delay or throttling on the server-side to see if that helps with the issue. Additionally, you could try using a different protocol such as TCP to see if that resolves the issue.
Have you tried any of these approaches?
Danya🔥
Ehsan
Michel
Is there a way in the standard library (std=c++17) to create a date-time object and add a deltatime?
dimazava
Michel
dimazava
Michel
Yeah, but that's since C++20
dimazava
Michel
Don't worry, thanks.
dimazava
I bet you've found this already, but nevertheless https://stackoverflow.com/a/70687148/5875417
dimazava
So with this basic math you can go whenever you want
greg
Hey guys
greg
I'm self taught C++ , still learning LoL
greg
I'm learning cuz it helps me understand Structured text on PLC
Pavel
Ludovic 'Archivist'
Ludovic 'Archivist'
Because it has no info on days and months and years
Ludovic 'Archivist'
For chrono, TAI and UTC are the same thing with just different epochs
Ludovic 'Archivist'
Technically, only Unix timestamps can be transparently converted to days (because they are not steady, there is some going back in time involved)
Anonymous
It doesn't need to before C++20
C++20 added partial support. Full support comes with C++23. In C++20, only leap second insertion was supported i.e. addition of leap seconds. C++23 supports both addition and subtraction.
Hellomik
Hi I am want use openCv package from source with only open cv without importing it in global path, because I will reuse it in another module connected with Flutter, that's why I should reuse Open cv as package in Cmake, can someone help me with that ?
Ludovic 'Archivist'
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Anonymous
sorry for dumb question.
can you recommend any paid course for c++.
or is youtube sufficient
i have done c++ from youtube but i dont feel FULL in cpp
I'm in 2nd sem.
3months are remaining for 3rd sem.
is leetcode necessary in 1st yr itself?
plz anyone tell
Null
hi
Chat Boss
Nickname Is sent a huge message, it has been re-uploaded as a file
structures.txt
name,11.11.2000
name2,9.7.1999
main.c
#include <stdio.h>
struct Info {
char..
IDCAN
Does anyone know why the catch block doesn't handle exception it's just crash? Any ideas?
Ziky
IDCAN
crash = segfault?
no, just stuck to few seconds with loading cursor and than crash
IDCAN
I'd to send picture with my code, but here it's doesn't allowed
Ziky
Have you tried it in debugger?
Ziky
doesn't it print it anything into terminal?
IDCAN
nothing, just crash
here an example of code:
int32_t func_to_be_called(...)
{
// code...
throw std::runtime_error("Error");
}
void caller_func()
{
try
{
func_to_be_called(...);
}
catch (std::runtime_error& e)
{
printf("%s", e.what());
}
}
klimi
what about valgrind?
IDCAN
may it be in case if I trying to delete smth in catch block?
Anonymous
hey guys, is codespaces usage completely free for student GitHub? please clear my doubt
Ziky
But just running it under debugger could tell you the place in code where OS killed you.
xuozea
i want to learn C++ from scratch, are there any resources available here?
Danya🔥