Ziky
at the first glance it looks you forgot to add length of body
Ziky
but what about stepping it in debugger?
Ya deway
btu looking into your example Content-Length: 0 looks like there is no body to print
I don't use the content length because it is often not used in requests (especially in get requests where normally there shouldn't be a body but there is anyway...)
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
Ya deway
what about the debugger?
Yeah i know... I havent it im only gcc for compilation, did u have any advice
Ziky
click one green button fork this on the top if you wan edit it or debug it
Ya deway
like this one ? https://onlinegdb.com/cdHVWXjmT
Yeah but da fuk in this site the function work like expected
Ziky
because I already commented out the line which was terminating your string at length of your headers by null characters
Ya deway
because I already commented out the line which was terminating your string at length of your headers by null characters
I had tried this solution, but unfortunately by doing so the printing is bad and unreadable characters appear, do you think it is because I have to add a string terminator at the end of the body? Thanks again
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
Ya deway
print your inputs before funvtion is called
I'll be home in a couple of hours, I'll let you know and thanks again
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
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?
Azri
https://t.me/cpp20programming
Wow, I appreciate the hardwork for that. Thanks!
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
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.
Thank you very much! What are the tools to check if code is slow?
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?
Ehsan
Michel
Is there a way in the standard library (std=c++17) to create a date-time object and add a deltatime?
Michel
maybe https://en.cppreference.com/w/cpp/chrono/time_point
Yes, I saw that, but how could I specify a date with time?
dimazava
Yes, I saw that, but how could I specify a date with time?
there's example code, which demonstrates how to calculate the day before, so...?
Michel
there's example code, which demonstrates how to calculate the day before, so...?
Yes, but it starts with the current date, I want to specify a different date.
Michel
Yeah, but that's since C++20
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
Ludovic 'Archivist'
I bet you've found this already, but nevertheless https://stackoverflow.com/a/70687148/5875417
Oh my god I take brain damage everytime someone decides to use UTC and ignore leap seconds and then proceeds to do anything milliseconds scale
Ludovic 'Archivist'
Doesn't chrono account for leap milliseconds?
It doesn't need to before C++20
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 ?
Ehsan
Hi, so the problem is that when many retransmission occur, a buffer client side is overwritten over the allowed dimension. That is, for some reason, unallowed memory chunks are overwritten, causing the segfault (confirmed by Valgrind). I can't change to TCP as this is a college project and I have to follow my professor's requests.
It sounds like the issue is caused by a buffer overflow on the client-side when many retransmissions occur. This can happen when data is written past the end of a buffer, causing a segmentation fault. One way to prevent this issue is to ensure that the buffer size is sufficient to handle the amount of data being transmitted and to validate that data is not being written past the end of the buffer. Have you tried increasing the buffer size or adding checks to prevent writing past the end of the buffer?
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?
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
may it be in case if I trying to delete smth in catch block?
It is not python, if you mess the memory program will start doing random things, if you try to access memory which is not allocated for you (which might be result doing random things) OS will kill you immediately.
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?